![]() ![]() This works great except that I'd like to give the product_name field a higher weighting than the brand field. Here is my data: POST /product_index/products/2Īnd here is my query: POST /product_index/_search Here are my mappings: POST /product_index In my index (products_index), I'd like to be able to query both the product_name field and the brand field. I'm using the Completion Suggester in Elasticsearch to allow partial word matching queries. Here is a tutorial to implement auto-complete menu targeting several fields You should give a try to Algolia -> the engine is designed to answer to prefix searches in realtime + having different "weights" per attribute. It's a simple "dictionary" designed to do "prefix" expansions faster than with an index + inverted lists. ![]() That's because the Completion Suggester doesn't do a "real search" -> it doesn't use the index. The only thing you can do is boost some entries but not the attributes inside an entry (see the weight options ). The Completion Suggester is actually pretty limited in term of scoring: you cannot do that. This implementation is however slower since it doesn't use suggesters. You can append the list of suggestions of brand-suggestion to the one of product suggestion, after having removed the duplicates, to have list of suggestions with only relevant suggestions, no duplicates and the product suggestions first.Īnother solution would be to use a query with boosting on brand and product, instead of using suggesters. When querying, make one suggest on both the brand and product suggesters: POST /product_index/_search When indexing, fill both fields: POST /product_index/products/2 My solution would be to make two suggester fields, one for brand and one for product name: POST /product_index So typically you would declare the type of a field to be a “string” or “integer” for example, but in this instance we need to use the special “completion” type.As redox said, the completion suggester is really simple and doesn't support entries boosting. I won’t go into the details of what a mapping is except to say it is a bit like a table schema in a relational database. The autosuggest items must be indexed using a document field whose “mapping” has been declared to be a “completion” type. Also, they automatically filter out duplicate results. I will show in later sections how autosuggest can be implemented using standard queries, but you should always consider using a Completion Suggester first as they are faster than standard queries (at least in theory). The Elasticsearch API supports quite complex general searches, but also has specific support for autosuggest in the form of its “ Completion Suggesters“. Like all software that uses Elasticsearch, an autosuggest system needs to interact with Elasticsearch via the Elasticsearch API. For an introduction to these, it is hard to beat the “ Getting Started” chapter of the online “ Elasticsearch Definitive Guide“. While hopefully not essential, it will help if the reader already has some familiarity with Elasticsearch, in particular the concepts of “index”, “index mapping”, and some of the basics of the query DSL. In what follows, I describe several different ways to use Elasticsearch to support autosuggest, starting with simple “completion suggesters” through to more sophisticated queries. All this makes it possible to use Elasticsearch as part of an autosuggest system. It is built on top of Apache Lucene and so it supports a nice range of natural language text analysis options and support for geo-spatial features. For example, would you like “Repetitive Strain Injury” to be a suggestion for “ strai“Įlasticsearch is a document store designed to support fast searches.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |