We are very interested into what use cases you might bring this functionality in and would love to hear back from you about this highly requested feature.The main features of the new Completion Suggester are: We intentionally left out a couple of possible mapping options in this quick introduction, which you might want to read up on in the context suggester documentation For example, the category id in your ecommerce site’s page, or the location and the type of a restaurant, or the type of point of interest you wanted to visit, etc etc. This principle is also the reason why you can have an unlimited amount of such graphs, as you just create a graph with more prefix graphs. The location is a geo_point, and you may be wondering how can this be a graph? The solution is simple: the geo point is converted into a geohash first – which is a string – and then a graph is created from the geohashes. The first one is for the type field and the second for the location. Internally, Elasticsearch is creating two prefix graphs (remember the cute graph in the completion suggester blogpost?) in addition to the usual suggestion graph. Next, index a new point of interest of type restaurant: PUT /venues/poi/1Īnd now, use the type context and the location context to find suggestions for restaurants in that area: POST /venues/_suggest There are just two in this example, but you can have arbitrarily many contexts! DELETE /venues So, let us create a new index with a new field mapping that contains two contexts. You can create a completion field mapping, which needs a field and a geo location in order to return suggestions. Even though this seems more tricky, the great part about the context suggester is the possibility of using several suggesters sequentially. So after understanding this principle, your next step would be to answer the question: “How can I find suggestions for all the Indian restaurants near my location?”. The next step is to index a document, which contains location information in the suggest field: PUT /venues/poi/1Īnd now, all of a sudden, you can get suggestions back which only apply to a certain area: POST /venues/_suggest Let us take care of the mapping first: DELETE /venues This means that you need to supply location information on query and index time. Ideally, we would filter the suggestions to include only those which are around 2km from the users’ location. Imagine you are retrieving suggestions for restaurants you probably want to suggest restaurants near the user. Using geo locationsĪnother interesting use case is to take geo locations into account. The second suggestion is ignored because it is a different type than article.Ī very common use case for this example would be an e-commerce shop imagine you have selected a category and only want to return products which are inside of the selected product category. Now a suggestion needs to contain context information: POST /posts/_suggest?pretty'īecause the suggester is using the article type as its context, only the first suggestion (“Medicine – Better than homeopathy?”) will be returned by the suggester. Now index two documents: PUT /posts/article/1 The mapping would look like this: DELETE /posts One common use case is when you want to return suggestions only for a certain type. The first possibility is to filter by fields. However, we wanted to show you a couple of examples of scoping a suggestion. You, the person using your data, will know best what the correct scope is. What can a scope include? Like with many things in Elasticsearch, there are endless possibilities. The name describes the difference between this one and other suggesters: users want to get suggestions back, but in the scope of a context. We spent some time thinking about this problem, and came up with a solution we call context suggestions. As the query being executed for a completion suggest request is not a real search request and the data structure being accessed differs, applying filters was not as simple as one would hope. One of the most requested requirements for the suggester was the possibility to apply filters to the suggestions. If you have not yet read the introductory blog post about the completion suggester, why we built it, and what makes it so fast, you should do so right now! Speed is nothing without control
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |