Created
February 26, 2021 14:25
-
-
Save dainiusjocas/ad549e11fb5c957a9bdbe66b7cda09bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE dismax-demo | |
PUT dismax-demo | |
{ | |
"mappings": { | |
"properties": { | |
"category": { | |
"type": "text" | |
} | |
} | |
} | |
} | |
POST /dismax-demo/_doc/1 | |
{"category":"Red Dress"} | |
POST /dismax-demo/_doc/2 | |
{"category":"Red Dresses"} | |
POST /dismax-demo/_doc/3 | |
{"category":"Dresses"} | |
POST /dismax-demo/_doc/4 | |
{"category":"Dress"} | |
GET dismax-demo/_refresh | |
GET dismax-demo/_search | |
{ | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"dis_max": { | |
"queries": [ | |
{ | |
"constant_score": { | |
"filter": { | |
"match": { | |
"category": { | |
"query": "red dress with dots", | |
"_name": "text" | |
} | |
} | |
}, | |
"boost": 0.2 | |
} | |
}, | |
{ | |
"constant_score": { | |
"filter": { | |
"match_phrase": { | |
"category": { | |
"query": "red dress", | |
"_name": "phrase" | |
} | |
} | |
}, | |
"boost": 1.2 | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"took" : 0, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 1, | |
"successful" : 1, | |
"skipped" : 0, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : { | |
"value" : 3, | |
"relation" : "eq" | |
}, | |
"max_score" : 1.2, | |
"hits" : [ | |
{ | |
"_index" : "dismax-demo", | |
"_type" : "_doc", | |
"_id" : "1", | |
"_score" : 1.2, | |
"_source" : { | |
"category" : "Red Dress" | |
}, | |
"matched_queries" : [ | |
"phrase", | |
"text" | |
] | |
}, | |
{ | |
"_index" : "dismax-demo", | |
"_type" : "_doc", | |
"_id" : "2", | |
"_score" : 0.2, | |
"_source" : { | |
"category" : "Red Dresses" | |
}, | |
"matched_queries" : [ | |
"text" | |
] | |
}, | |
{ | |
"_index" : "dismax-demo", | |
"_type" : "_doc", | |
"_id" : "4", | |
"_score" : 0.2, | |
"_source" : { | |
"category" : "Dress" | |
}, | |
"matched_queries" : [ | |
"text" | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment