Simple search doesnt work

When i do this search, my product is well find :

{
  "query": {
    "bool": {
      "must": [
        { "match": { "pickRef": "630203" } },
        { "match": { "id": 56139 } },
        { "match": { "name.fr": "ENVELOPPE" } }
      ]
    }
  }
}

But when i do this, he dont find my product :

{
  "query": {
    "bool": {
      "must": [
        { "match": { "name.fr": "ENVELOPPE" } }
      ]
    }
  }
}

Here my product :

"hits" : [
      {
        "_index" : "product_prod",
        "_type" : "_doc",
        "_id" : "56139",
        "_score" : 76.868805,
        "_source" : {
          "id" : 56139,
          "name" : {
            "fr" : "ENVELOPPE 239/324/20 STRIP BEIGE FOND VERT 120G ELCO DOCUMENTO - boîte de 200"
          },
          "pickRef" : "630203",
...

Do you have an idea why he cant found by searching only on name ?

Hi @Dach

This query should work. Provides index mapping for parsing the type of the name field.

Thanks for the reply, here my configuration

{
	"product_dev": {
		"aliases": {},
		"mappings": {
			"properties": {
				"id": {
					"type": "keyword"
				},
				"name": {
					"properties": {
						"de": {
							"type": "text",
							"boost": 3,
							"fields": {
								"keyword": {
									"type": "keyword",
									"ignore_above": 256
								}
							},
							"analyzer": "german"
						},
						"en": {
							"type": "text",
							"boost": 3,
							"fields": {
								"keyword": {
									"type": "keyword",
									"ignore_above": 256
								}
							},
							"analyzer": "english"
						},
						"fr": {
							"type": "text",
							"boost": 3,
							"fields": {
								"keyword": {
									"type": "keyword",
									"ignore_above": 256
								}
							},
							"analyzer": "french"
						}
					}
				},
				"pickRef": {
					"type": "keyword",
					"boost": 5
				}
			}
		},
		"settings": {
			"index": {
				"routing": {
					"allocation": {
						"include": {
							"_tier_preference": "data_content"
						}
					}
				},
				"number_of_shards": "1",
				"provided_name": "product_dev",
				"creation_date": "1687963075592",
				"analysis": {
					"filter": {
						"autocomplete_filter": {
							"type": "edge_ngram",
							"min_gram": "1",
							"max_gram": "20"
						}
					},
					"analyzer": {
						"autocomplete": {
							"filter": [
								"lowercase",
								"autocomplete_filter"
							],
							"type": "custom",
							"tokenizer": "standard"
						}
					},
					"char_filter": {
						"pre_negs": {
							"pattern": "a \\w",
							"type": "pattern_replace",
							"replacement": ""
						}
					}
				},
				"number_of_replicas": "0",
				"uuid": "....",
				"version": {
					"created": "7170699"
				}
			}
		}
	}
}

Maybe it's because my product don't have enought score ?

I reproduce the scenario and got the results for both queries. Maybe and other query you use other language instead of france.

PUT idx_test/
{
  "mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "name": {
        "properties": {
          "de": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            },
            "analyzer": "german"
          },
          "en": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            },
            "analyzer": "english"
          },
          "fr": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            },
            "analyzer": "french"
          }
        }
      },
      "pickRef": {
        "type": "keyword"
      }
    }
  },
  "settings": {
    "analysis": {
      "filter": {
        "autocomplete_filter": {
          "type": "edge_ngram",
          "min_gram": "1",
          "max_gram": "20"
        }
      },
      "analyzer": {
        "autocomplete": {
          "filter": [
            "lowercase",
            "autocomplete_filter"
          ],
          "type": "custom",
          "tokenizer": "standard"
        }
      },
      "char_filter": {
        "pre_negs": {
          "pattern": """a \w""",
          "type": "pattern_replace",
          "replacement": ""
        }
      }
    }
  }
}

Doc

PUT idx_test/_doc/2
{
  "id": 56139,
  "name": {
    "fr": "ENVELOPPE 239/324/20 STRIP BEIGE FOND VERT 120G ELCO DOCUMENTO - boîte de 200"
  },
  "pickRef": "630203"
}

Queries


GET idx_test/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "name.fr": "ENVELOPPE" } }
      ]
    }
  }
}

GET idx_test/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "pickRef": "630203" } },
        { "match": { "id": 56139 } },
        { "match": { "name.fr": "ENVELOPPE" } }
      ]
    }
  }
}

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