Can some let know about the use of ~ & ^ in below syntax


(Vani Aravinda) #1

(
(
TITLE:"same old song and dance"^100
OR (
TITLE:same~0.8 AND TITLE:old~0.8 AND TITLE:song~0.8 AND TITLE:and~0.8 AND TITLE:dance~0.8
)^50
OR (
TITLE:same~0.5 AND TITLE:old~0.5 AND TITLE:song~0.5 AND TITLE:and~0.5 AND TITLE:dance~0.5
)^10
)^500
AND (
COMPOSERS:perry ~2^2 OR COMPOSERS:tallarico ~2^2 OR COMPOSERS:perry, tallarico~2^2
)
)^100

Please explain about ^ & ~ in above query.


(Magnus B├Ąck) #2

^ is for boosting while ~ in this case is for adjusting the fuzziness.


(Vani Aravinda) #3

Hi @magnusbaeck,

TanQ for ur quickly reply. Can u plz let me know the issue in my below query. Title "SAME OLD SONG AND DANCE" should be the first result set. But it is showing as second result with the score less than the first result.

Query :
POST /titles/title/_search
{
"query" : {
"bool" : {
"should" : [
{
"fuzzy" : {
"title" : {
"boost" : 100,
"value" : "same old song and dance"
}
}
},
{
"fuzzy" : {
"title" : {
"boost" : 50,
"value" : "same",
"fuzziness": 0.8
}
}
},
{
"fuzzy" : {
"title" : {
"boost" : 10,
"value" : "song",
"fuzziness": 0.5
}
}
}
]
}
}
}

Output:
{
"took": 125,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 0.39223227,
"hits": [
{
"_index": "titles",
"_type": "title",
"_id": "4",
"_score": 0.39223227,
"_source": {
"title": "MY SAME SONG",
"composer": "pery"
}
},
{
"_index": "titles",
"_type": "title",
"_id": "1",
"_score": 0.34320325,
"_source": {
"title": "SAME OLD SONG AND DANCE",
"composer": "perry"
}
},
{
"_index": "titles",
"_type": "title",
"_id": "3",
"_score": 0.16666667,
"_source": {
"title": "SONG AND DANCE",
"composer": "perry/tallarico"
}
},
{
"_index": "titles",
"_type": "title",
"_id": "5",
"_score": 0.051142137,
"_source": {
"title": "DANCE AND SONG",
"composer": "SE"
}
}
]
}
}


(system) #4