I am using fuzzy
and want elasticsearch to return the searched word not just the hit.
When i am searching for the word dogo
and my fuzzy search finds the word dog
i want to know that it was dogo
who found it.
data:
{ "index": { "_id":1 }}
{ "title": "The quick brown fox", "price":5 }
{ "index": { "_id":2 }}
{ "title": "The quick blue dog", "price":7 }
{ "index": { "_id":3 }}
{ "title": "The slow brown dog", "price":5 }
query:
{
"query": {
"bool": {
"should": [
{
"fuzzy": {
"title": "dogo"
}
},
{
"fuzzy": {
"title": "fox"
}
}
]
}
},
"highlight" : {
"fields" : {
"title":{
"pre_tags": [
"===>"
],
"post_tags": [
"<==="
],
"fragment_size": 200,
"number_of_fragments": 100
}
}
}
}
This query will return ===>dog<===
but don't know if dogo
found it.
Does anyone know how to do this or an idea?
I want my output to be something like dog : dogo
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…