Hello again!
Thanks for the answer.
I will provide some more information and also some conclusions.
First, this is my Mapping settings:
{
"properties": {
"id": {"type": "long"},
"uuid": {"type": "keyword"},
"sku": {"type": "keyword"},
"description": {
"type": "text",
"fields": {
"folded": {"type": "text", "analyzer": "folding"},
"fuzzy": {"type": "text", "analyzer": "simple"},
"raw": {"type": "keyword"}
}
},
"normDescription": {
"type": "text",
"fields": {
"folded": {"type": "text", "analyzer": "folding"},
"fuzzy": {"type": "text", "analyzer": "simple"},
"raw": {"type": "keyword"}
}
}
}
}
And my Search:
{
"from": 0,
"size": 10,
"_source": ["description"],
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"match_phrase_prefix": {
"normDescription": {
"query": "Cracha*",
"boost": 2
}
}
},
{
"query_string": {
"query": "Cracha",
"fields": ["sku","uuid"],
"minimum_should_match": "1"
}
},
{
"match": {
"normDescription.fuzzy": {
"query": "Cracha",
"fuzziness": 2,
"prefix_length": 3,
"minimum_should_match": 2
}
}
}
]
}
}
]
}
}
}
I'm using this source instruction, just to bring the description, just to make the return smaller, this will not be used in the future, it's just for testing.
The return was like this:
{
"_index": "sb_product",
"_type": "_doc",
"_id": "pb01sb_41392",
"_score": 72.157036,
"_source": {
"description": "Cordão para Cracha"
},
"sort": [
72.157036,
"Cordão para Cracha"
]
},
{
"_index": "sb_product",
"_type": "_doc",
"_id": "pb01sb_41536",
"_score": 64.49333,
"_source": {
"description": "Cracha de outro fornecedor"
},
"sort": [
64.49333,
"Cracha de outro fornecedor"
]
}
Register "Cordão para Cracha":
_score: 7.330924
IDF (7.9352293), TF (0.41992968)
Register "Cracha de outro fornecedor":
_score: 6.3671646
IDF (7.9352293), TF (0.36472368)
So I had an idea to simply change the name of the product, from "Cordão para Chacha" to "Cordão diversos para cracha"
So for some reason, the record length impacts the TF calculation.
So, the result was this:
{
"_index": "sb_product",
"_type": "_doc",
"_id": "pb01sb_41536",
"_score": 15.399356,
"_source": {
"description": "Cracha de outro fornecedor"
}
},
{
"_index": "sb_product",
"_type": "_doc",
"_id": "pb01sb_41392",
"_score": 15.399356,
"_source": {
"description": "Cordão diversos para cracha"
}
}