Simple query "match" relevance

Hi all,
I'm a bit surprised with the result of the query (see the code below)
I would expect the doc 4 to be first ... but this is the 1, 2, 5,6,3,4
If anyone can help.

Thanks a lot

DELETE shop
PUT shop
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
      "properties": {
        "title": {
          "type": "text"
        },
        "title_full": {
          "type": "text"
        },
        "colour": {
          "type": "keyword"
        },
        "brand": {
          "type": "text"
        },
        "size": {
          "type": "text"
        },
        "price": {
          "type": "double"
        },
        "family_id": {
          "type": "keyword"
        }
      }
  }
}

POST shop/_doc/1
{
  "title": "iPad Air 2",
  "title_full": "iPad Air 2 Silver Apple 32gb",
  "colour": "Silver",
  "brand": "Apple",
  "size": "32gb",
  "price": 399,
  "family_id": "apple-1234"
}

POST shop/_doc/2
{
  "title": "iPad Air 2",
  "title_full": "iPad Air 2 Gold Apple 32gb",
  "colour": "Gold",
  "brand": "Apple",
  "size": "32gb",
  "price": 399,
  "family_id": "apple-1234"
}

POST shop/_doc/3
{
  "title": "iPad Air 2",
  "title_full": "iPad Air 2 Space grey Apple 32gb",
  "colour": "Space Grey",
  "brand": "Apple",
  "size": "32gb",
  "price": 399,
  "family_id": "apple-1234"
}

POST shop/_doc/4
{
  "title": "iPad Air 2",
  "title_full": "iPad Air 2 Space Grey Apple cccdd",
  "colour": "Space Grey",
  "brand": "Apple",
  "size": "128gb",
  "price": 499,
  "family_id": "apple-1234"
}

POST shop/_doc/5
{
  "title": "iPad Pro",
  "title_full": "iPad Pro Space Grey Apple 128gb",
  "colour": "Space Grey",
  "brand": "Apple",
  "size": "128gb",
  "price": 899,
  "family_id": "apple-5678"
}

POST shop/_doc/6
{
  "title": "iPad Pro",
  "title_full": "iPad Pro Space Grey Apple 256gb",
  "colour": "Space Grey",
  "brand": "Apple",
  "size": "256gb",
  "price": 999,
  "family_id": "apple-5678"
}

GET shop/_search
{
  "query": {
    "match": {
      "title_full": "ipad ccc"
    }
  }
}```

Hi @Guillaume_R

Run the analyze API to understand the generated tokens. Due to the configuration of your mapping I believe that there is no corresponding to the term ccc because the token generated for "iPad Air 2 Space Gray Apple cccdd" would be "cccdd".

GET shop/_analyze
{
  "field": "title_full",
  "text": ["iPad Air 2 Space Grey Apple cccdd"]
}

If you use fuzziness you may have this more relevant document 4 in the answers.

GET shop/_search
{
  "query": {
    "match": {
      "title_full": {
        "query": "ipad ccc",
        "fuzziness": 2
      }
      
    }
  }
}

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