This question summarizes aspects like the duties, skills required for the job, who you would be accountable to and are accountable to you. It gives you a brief idea about the work associated with the position.
Any corporate job will demand a specific set of skills. To be capable and perform the duties without any errors, you need to possess the expertise to handle the role. The above question lets you learn about the required skills along with other qualifications needed for position.
This question lets you know about two things: demand for the job and the strictness of candidate assessment. If the job has been open over a month, there is a high probability of people not being interested in the job. Alternatively, it could also mean that the candidates are failing to make through the interviews due to strict interview conditions. Then again, you might get to know that the job has been open for only a week. In that case, you do not get any idea about the competition for the job or the interviewer’s meticulousness.
Sometimes companies have a change in management which might also result in the creation of some new roles and designations. Or, there might be a change in ideas and priorities which creates new job titles. Then again, an open position could be a consequence of a change in the workforce (like promotion, retirement, or firing [in extreme cases]). You are not looking for a right or wrong answer to this question. It only lets you understand the circumstances which led to the availability of the job.
There are preliminary conditions set for a specific job; meeting them makes a candidate eligible for the position after which the interview process follows. Asking the recruiter about the cause of non-selection of other candidates might reveal potential shortcomings you need to careful of. It could be related to a skill, experience or any other aspect. Being aware of the things gives you forewarning – providing time to work out the inadequacies to perform better in the interview.
A job comes with associated duties, tasks that you need to do and are ultimately responsible for. Knowing the challenges and opportunities that you will encounter in the position gives you time to prepare yourself mentally. It won’t feel like a bad surprise when you face the issue later down the road. It will also help you evaluate your career progression, letting you know if the job matches your intentions and ambitions.
People want gradual progress their careers, be it in the form of salary increases, increase in responsibilities or job title. Through this question you get to know the perks of working in the position.
Inquiring about pay gives you a salary number that the company is willing to compensate for the position. Not only do you get to know how much you might get paid, but it also lets you assess the value. Value relating the job responsibilities. This information also allows you to consider and compare other offers (if any).P
When working in any job, you will be a small part of the big system, i.e., the company. All organizations are different, and so are their principles. You should be appropriately informed about the work ethics and culture of the company. Ensure that it matches your preferences before deciding to join them.
The following questions intend to explore those topics.
Every company has their own rules when it comes to conducting interviews and hiring employees. Asking the recruiter provides insight into the process. Whether there is a preliminary written test, whether there is a phone interview before the actual meeting and more. Knowing these small details allows you to prepare accordingly to perform better.
The training, in this context, could be related to the period before being assigned any work, or during the working period to improve your skills and help in career development. Some companies actively engage their employees in training programs while others don’t. This information will be vital to shaping your career growth plan.
Companies don’t just hire people and forget about them. They tend to keep track of their work and performance. Your performance matches closely to their expectations. If not, you risk getting demoted (or in worse cases, fired from the job). There are usually parameters that help employers evaluate their employees’ performance. Inquiring about them in advance will let you know the factors you’ll be judged.
Every company has a system based on work ethics and culture which varies from one organization to the other. Google does away with formal wear while the company in question might be mandating that you dress formally. Formal wear is just one aspect. Knowing the principles that the company relies on and how it relates to your future work will help you make an informed decision.
The hiring manager is usually the one you will be reporting to before joining the company. It might be that the recruiter and the hiring manager are close acquaintances. Alternatively, that might not be the case. This question is to assess the relationship between the recruiter and the hiring manager while also letting you know more about the manager. This additional information (like their technical background, history with the company) will help you communicate with them during the interview process.
Asking this question will sum up the recruiter’s impression of the company. They might provide useful insight that could help you make a decision.
October 4, 2019
Elasticsearch, like most NoSQL databases, treats the world as though it were flat. An index is a flat collection of independent documents. A single document should con‐ tain all of the information that is required to decide whether it matches a search request.
Denormalizing your Data
The way to get the best search performance out of Elasticsearch is to use it as it is intended, by denormalizing your data at index time. Having redundant copies of data in each document that requires access to it removes the need for joins.
If we want to be able to find a blog post by the name of the user who wrote it, include the user’s name in the blog-post document itself.
PUT /users/blogpost/2 { "title": "Today Spirit", "body": "Let's go!", "user": { "id": 1, "name": "Folau Kaveinga" } }
Of course, data denormalization has downsides too. The first disadvantage is that the index will be bigger because the _source document for every blog post is bigger, and there are more indexed fields. This usually isn’t a huge problem. The data written to disk is highly compressed, and disk space is cheap. Elasticsearch can happily cope with the extra data.
The more important issue is that, if the user were to change his name, all of his blog posts would need to be updated too. Fortunately, users don’t often change names. Even if they did, it is unlikely that a user would have written more than a few thou‐ sand blog posts, so updating blog posts with the scroll and bulk APIs would take less than a second.
Given the fact that creating, deleting, and updating a single document in Elasticsearch is atomic, it makes sense to store closely related entities within the same document. For instance, we could store an order and all of its order lines in one document, or we could store a blog post and all of its comments together, by passing an array of comments.
Note that each nested object is indexed as a hidden separate document. Because nested objects are indexed as separate hidden documents, we can’t query them directly. Instead, we have to use the nested query or nested filter to access them.
By indexing each nested object separately, the fields within the object maintain their relationships. We can run queries that will match only if the match occurs within the same nested object.
Not only that, because of the way that nested objects are indexed, joining the nested documents to the root document at query time is fast—almost as fast as if they were a single document.
These extra nested documents are hidden; we can’t access them directly. To update, add, or remove a nested object, we have to reindex the whole document. It’s impor‐ tant to note that, the result returned by a search request is not the nested object alone; it is the whole document.
When should you user nested objects?
Nested objects are useful when there is one main entity, like our user, with a limited number of closely related but less important entities, such as addresses. It is useful to be able to find addresses based on the content of the street or zipcode, and the nested query and filter provide for fast query-time joins.
Retiring Data
As time-based data ages, it becomes less relevant. It’s possible that we will want to see what happened last week, last month, or even last year, but for the most part, we’re interested in only the here and now. The nice thing about an index per time frame is that it enables us to easily delete old data: just delete the indices that are no longer relevant.
A geo-point is a single latitude/longitude point on the Earth’s surface. Geo-points can be used to calculate distance from a point, to determine whether a point falls within a bounding box, or in aggregations.
Geo-points cannot be automatically detected with dynamic mapping. Instead, geo_point fields should be mapped explicitly.
PUT /elasticsearch_learning { "mappings": { "addresses": { "properties": { "location": { "type": "geo_point" } } } } }
With the location field defined as a geo_point, we can proceed to index documents containing latitude/longitude pairs, which can be formatted as strings, arrays, or objects.
Geo Distance Filter(geo_distance)
The geo_distance filter draws a circle around the specified location and finds all documents that have a geo-point within that circle.
Find all location fields within 1 miles of the specified point.
GET elasticsearch_learning/_search { "query":{ "nested" : { "query" : { "bool" : { "filter" : [ { "geo_distance" : { "addresses.location" : [ -111.881186, 40.414897 ], "distance" : 1609.344, "distance_type" : "arc", "validation_method" : "STRICT", "ignore_unmapped" : false, "boost" : 1.0 } } ], "adjust_pure_negative" : true, "boost" : 1.0 } }, "path" : "addresses", "ignore_unmapped" : false, "score_mode" : "none", "boost" : 1.0 } } }
/** * https://www.elastic.co/guide/en/elasticsearch/reference/7.x/query-dsl-nested-query.html<br> * https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html */ @Test void searchWithGeopoint() { int pageNumber = 0; int pageSize = 3; SearchRequest searchRequest = new SearchRequest(database); searchRequest.allowPartialSearchResults(true); searchRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.from(pageNumber * pageSize); searchSourceBuilder.size(pageSize); searchSourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS)); /** * fetch only a few fields */ searchSourceBuilder.fetchSource(new String[]{"*"}, new String[]{"cards"}); // searchSourceBuilder.fetchSource(new FetchSourceContext(true, new String[]{"*"}, new String[]{"cards"})); /** * Query with bool */ BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); /** * Lehi skate park: 40.414897, -111.881186<br> * get locations/addresses close to skate park(from a radius).<br> * The geo_distance filter can work with multiple locations / points per document. Once a single location / * point matches the filter, the document will be included in the filter. */ boolQuery.filter(QueryBuilders.geoDistanceQuery("addresses.location").point(40.414897, -111.881186).distance(1, DistanceUnit.MILES)); searchSourceBuilder.query(QueryBuilders.nestedQuery("addresses", boolQuery, ScoreMode.None)); searchRequest.source(searchSourceBuilder); searchRequest.preference("nested-address"); if (searchSourceBuilder.sorts() != null && searchSourceBuilder.sorts().size() > 0) { log.info("\n{\n\"query\":{}, \"sort\":{}\n}", searchSourceBuilder.query().toString(), searchSourceBuilder.sorts().toString()); } else { log.info("\n{\n\"query\":{}\n}", searchSourceBuilder.query().toString()); } try { SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT); log.info("isTimedOut={}, totalShards={}, totalHits={}", searchResponse.isTimedOut(), searchResponse.getTotalShards(), searchResponse.getHits().getTotalHits().value); List<User> users = getResponseResult(searchResponse.getHits()); log.info("results={}", ObjectUtils.toJson(users)); } catch (IOException e) { log.warn("IOException, msg={}", e.getLocalizedMessage()); e.printStackTrace(); } catch (Exception e) { log.warn("Exception, msg={}", e.getLocalizedMessage()); e.printStackTrace(); } }
Geo Bounding Box(geo_bounding_box) Filter
This is by far the most efficient geo-filter because its calculation is very simple. You provide it with the top, bottom, left, and right coordinates of a rectangle, and all it does is compare the latitude with the left and right coordinates, and the longitude with the top and bottom coordinates.
GET elasticsearch_learning/_search { "query":{ "nested" : { "query" : { "bool" : { "filter" : [ { "geo_bounding_box" : { "addresses.location" : { "top_left" : [ 112.025029, 40.526588 ], "bottom_right" : [ 0.0, 0.0 ] }, "validation_method" : "STRICT", "type" : "MEMORY", "ignore_unmapped" : false, "boost" : 1.0 } } ], "adjust_pure_negative" : true, "boost" : 1.0 } }, "path" : "addresses", "ignore_unmapped" : false, "score_mode" : "none", "boost" : 1.0 } } }
/** * https://www.elastic.co/guide/en/elasticsearch/reference/7.x/query-dsl-nested-query.html<br> * https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html */ @Test void searchWithGeoBoundingBox() { int pageNumber = 0; int pageSize = 3; SearchRequest searchRequest = new SearchRequest(database); searchRequest.allowPartialSearchResults(true); searchRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.from(pageNumber * pageSize); searchSourceBuilder.size(pageSize); searchSourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS)); /** * fetch only a few fields */ searchSourceBuilder.fetchSource(new String[]{"id","firstName","lastName","addresses.street","addresses.city","addresses.zipcode"}, new String[]{"cards"}); /** * Query with bool */ BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); /** * topLeft: herriman<br> * bottomRight: american folk */ boolQuery.filter(QueryBuilders.geoBoundingBoxQuery("addresses.location") .setCorners(new GeoPoint(40.526588, 112.025029), new GeoPoint(0.0, 0.0))); searchSourceBuilder.query(QueryBuilders.nestedQuery("addresses", boolQuery, ScoreMode.None)); searchRequest.source(searchSourceBuilder); searchRequest.preference("nested-address"); if (searchSourceBuilder.sorts() != null && searchSourceBuilder.sorts().size() > 0) { log.info("\n{\n\"query\":{}, \"sort\":{}\n}", searchSourceBuilder.query().toString(), searchSourceBuilder.sorts().toString()); } else { log.info("\n{\n\"query\":{}\n}", searchSourceBuilder.query().toString()); } try { SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT); log.info("isTimedOut={}, totalShards={}, totalHits={}", searchResponse.isTimedOut(), searchResponse.getTotalShards(), searchResponse.getHits().getTotalHits().value); List<User> users = getResponseResult(searchResponse.getHits()); log.info("results={}", ObjectUtils.toJson(users)); } catch (IOException e) { log.warn("IOException, msg={}", e.getLocalizedMessage()); e.printStackTrace(); } catch (Exception e) { log.warn("Exception, msg={}", e.getLocalizedMessage()); e.printStackTrace(); } }
Scoring by Distance
It may be that distance is the only important factor in deciding the order in which results are returned, but more frequently we need to combine distance with other factors, such as full-text relevance, popularity, and price.
In these situations, we should reach for the function_score query that allows us to blend all of these factors into an overall score.
The other drawback of sorting by distance is performance: the distance has to be cal‐ culated for all matching documents. The function_score query, on the other hand, can be executed during the rescore phase, limiting the number of calculations to just the top n results.