Forked from nekulin/ElasticSearch Highlighting
Last active
December 16, 2015 19:50
-
-
Save imotov/5488014 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
curl -XDELETE "http://localhost:9200/test/" | |
curl -XPUT "http://localhost:9200/test/" -d '{ | |
"mappings": { | |
"product": { | |
"properties": { | |
"doc": { | |
"properties": { | |
"name": { | |
"type": "string", | |
"include_in_all": true | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
# Insert | |
curl -XPUT "http://localhost:9200/test/product/1" -d '{ "doc":{"name":"Горчица"} }' | |
curl -XPUT "http://localhost:9200/test/product/2" -d '{ "doc":{"name":"Молоко"} }' | |
curl -XPUT "http://localhost:9200/test/product/3" -d '{ "doc":{"name":"Кефир жирный 2"} }' | |
curl -XPUT "http://localhost:9200/test/product/4" -d '{ "doc":{"name":"Кефир жирный"} }' | |
curl -XPUT "http://localhost:9200/test/product/5" -d '{ "doc":{"name":"Виски"} }' | |
curl -XPOST "http://localhost:9200/test/_refresh" | |
# Search highlight | |
curl -XPOST "http://localhost:9200/test/product/_search?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>" | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment