Dach
June 28, 2023, 1:54pm
1
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 ?
RabBit_BR
(andre.coelho)
June 28, 2023, 2:45pm
2
Hi @Dach
This query should work. Provides index mapping for parsing the type of the name field.
Dach
June 29, 2023, 5:47am
3
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"
}
}
}
}
}
Dach
June 29, 2023, 5:48am
4
Maybe it's because my product don't have enought score ?
RabBit_BR
(andre.coelho)
June 29, 2023, 11:21am
5
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" } }
]
}
}
}
system
(system)
Closed
July 27, 2023, 11:21am
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.