Created
April 30, 2013 05:42
-
-
Save nekulin/5486789 to your computer and use it in GitHub Desktop.
ElasticSearch Highlighting
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
Mapping | |
{ | |
"product" : { | |
"properties" : { | |
"doc" : { | |
"properties" : { | |
"name" : { | |
"type" : "string", | |
"include_in_all" : true | |
} | |
} | |
} | |
} | |
} | |
} | |
// Insert | |
curl -XPOST "http://localhost:9200/test/product/1" -d '{ "doc":{"name":"Горчица"} }' | |
curl -XPOST "http://localhost:9200/test/product/2" -d '{ "doc":{"name":"Молоко"} }' | |
curl -XPOST "http://localhost:9200/test/product/3" -d '{ "doc":{"name":"Кефир жирный 2"} }' | |
curl -XPOST "http://localhost:9200/test/product/4" -d '{ "doc":{"name":"Кефир жирный"} }' | |
curl -XPOST "http://localhost:9200/test/product/5" -d '{ "doc":{"name":"Виски"} }' | |
// Search highlight | |
curl -XPOST "http://localhost:9200/test/product?pretty=true" -d ' | |
{ | |
"query": { | |
"query_string": { | |
"query": "doc.name:Молоко", | |
"analyzer": "standard" | |
} | |
}, | |
"highlight": { | |
"number_of_fragments": 0, | |
"fields": { | |
"doc.name": {} | |
}, | |
"pre_tags": "<b>", | |
"post_tags": "</b>" | |
} | |
} | |
' | |
Найденое молоко не выделилось тегами <b></b> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment