Created
December 29, 2016 04:19
-
-
Save mahadazad/8440e3ea4a0e2c3084e3394db8b32f43 to your computer and use it in GitHub Desktop.
Elastic Search - Search With Hyphens
This file contains hidden or 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
PUT /store | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"whitespaced": { | |
"type": "custom", | |
"char_filter": ["html_strip"], | |
"tokenizer": "whitespace", | |
"filter": ["lowercase"] | |
} | |
} | |
} | |
} | |
} | |
PUT /store/_mapping/product | |
{ | |
"properties": { | |
"title": { | |
"type": "string", | |
"analyzer": "english", | |
"fields": { | |
"whitespaced": { | |
"type": "string", | |
"analyzer": "whitespaced" | |
} | |
} | |
}, | |
"description": { | |
"type": "string", | |
"analyzer": "english", | |
"fields": { | |
"whitespaced": { | |
"type": "string", | |
"analyzer": "whitespaced" | |
} | |
} | |
} | |
} | |
} | |
GET /store/product/_search | |
{ | |
"query": { | |
"multi_match": { | |
"fields": ["title.whitespaced^15", "title^10", "description.whitespaced^5", "description"], | |
"query": "preworkout", | |
"fuzziness": "AUTO" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment