Search query not fethcing all the results

If am searching for italian marble flooring need to search for a combination of the below with the priority

1. italian marble flooring
2. italian marble
3. marble flooring
4. italian flooring
5. italian
6. marble
7. flooring

Query which am using to fetch the data.

Query

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "keywords.keyword_values": {
              "query": "italian marble flooring"
            }
          }
        }
      ]
    }
  }
}

Doc 1

{
  "keywords": [
    {
      "keyword_values": "italian marble flooring"
    }
  ]
}

Doc 2

{
  "keywords": [
    {
      "keyword_values": "italian marble"
    }
  ]
}

Doc 3

{
  "keywords": [
    {
      "keyword_values": "marble flooring"
    }
  ]
}

Doc 4

{
  "keywords": [
    {
      "keyword_values": "italian flooring"
    }
  ]
}

Doc 5

{
  "keywords": [
    {
      "keyword_values": "italian"
    }
  ]
}

Doc 6

{
  "keywords": [
    {
      "keyword_values": "marble"
    }
  ]
}

Doc 7

{
  "keywords": [
    {
      "keyword_values": "flooring"
    }
  ]
}

Hi @Mohan_T,

I don't quite follow the issue you're having with the provided query. Which documents are you finding are not returned by your query that you expect to be returned?

Doc 1 only am getting, else am not getting.

Ok, can you share your index mapping? Do you only have a keyword field for this data, or do you also have a corresponding text field?

{
  "indexname": {
    "mappings": {
      "properties": {
        "keywords": {
          "properties": {
            "keyword_values": {
              "type": "text"
            }
          }
        }
      }
    }
  }
}

Is that the mapping you are getting using the get mapping API? If so please make sure to provide the full output.

In previous posts you have been using custom analysers for this field. Is this something you have now dropped?

this is the one am using, there is no custom analyzer

I just tested this and the query you privided returned all 7 test documents. Please provide a complete script (API calls to create mappings, index documents and run the query) that recreates your issue and also let us know which version of Elasticsearch you are using. Without this it is impossible to see what you have done wrong or left out, which results in a lot of wasted time.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.