Elasticsearch Compliance

How do I search for a matching match?

those. At the moment I have a lot of documents containing the word "skateboard" in the item_title field, but only 3 documents containing the word "skateboards". Because of this, when I do the following search:

 POST /my_index/my_type/_search { "size": 100, "query" : { "multi_match": { "query": "skateboards", "fields": [ "item_title^3" ] } } } 

I get only 3 results. However, I would also like to return the documents with the word โ€œskateboardโ€.

From what I understand from Elasticsearch, I would expect this to be done by specifying a mapping in the item_title field, which contains an analyzer that indexes the source version of each word, but I cannot find documentation on how to do this, which suggests that it is done differently.

Suggestions?

+7
search elasticsearch stem
source share
1 answer

Here is an example:

 PUT /stem { "settings": { "analysis": { "filter": { "filter_stemmer": { "type": "stemmer", "language": "english" } }, "analyzer": { "tags_analyzer": { "type": "custom", "filter": [ "standard", "lowercase", "filter_stemmer" ], "tokenizer": "standard" } } } }, "mappings": { "test": { "properties": { "item_title": { "analyzer": "tags_analyzer", "type": "string" } } } } } 

Indicate some sample documents:

 POST /stem/test/1 { "item_title": "skateboards" } POST /stem/test/2 { "item_title": "skateboard" } POST /stem/test/3 { "item_title": "skate" } 

Run the request:

 GET /stem/test/_search { "query": { "multi_match": { "query": "skateboards", "fields": [ "item_title^3" ] } }, "fielddata_fields": [ "item_title" ] } 

And look at the results:

  "hits": [ { "_index": "stem", "_type": "test", "_id": "1", "_score": 1, "_source": { "item_title": "skateboards" }, "fields": { "item_title": [ "skateboard" ] } }, { "_index": "stem", "_type": "test", "_id": "2", "_score": 1, "_source": { "item_title": "skateboard" }, "fields": { "item_title": [ "skateboard" ] } } ] 

I also added a fielddata_fields element so you can see how the contents of the field have been indexed. As you can see, in both cases the indexed member is a skateboard .

+7
source share

All Articles