-
-
Save imotov/73fcd9f3e19165802e14 to your computer and use it in GitHub Desktop.
shingles
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 localhost:9200/shingles | |
echo | |
curl -XPUT localhost:9200/shingles -d '{ | |
"mappings": { | |
"post": { | |
"properties": { | |
"body": { | |
"fields": { | |
"body": { | |
"type": "string", | |
"analyzer": "analyzer_term" | |
}, | |
"partial_shingle": { | |
"search_analyzer": "analyzer_term", | |
"index_analyzer": "analyzer_partial_shingle", | |
"type": "string" | |
} | |
}, | |
"type": "multi_field" | |
} | |
} | |
} | |
}, | |
"settings": { | |
"index.number_of_shards": 1, | |
"index.number_of_replicas": 0, | |
"analysis": { | |
"filter": { | |
"filter_partial_shingle": { | |
"type": "shingle", | |
"max_shingle_size": 5, | |
"min_shingle_size": 2, | |
"output_unigrams": "false" | |
} | |
}, | |
"analyzer": { | |
"analyzer_term": { | |
"filter": ["lowercase", "asciifolding"], | |
"type": "custom", | |
"tokenizer": "whitespace" | |
}, | |
"analyzer_partial_shingle": { | |
"filter": ["lowercase", "asciifolding", "filter_partial_shingle"], | |
"type": "custom", | |
"tokenizer": "whitespace" | |
} | |
} | |
} | |
} | |
} | |
' | |
echo | |
curl -XPUT localhost:9200/shingles/post/1 -d '{ | |
"body": "Great Planes Rotor Blade" | |
}' | |
echo | |
curl -XPOST localhost:9200/shingles/_refresh | |
echo | |
curl "localhost:9200/shingles/post/_search?pretty=true" -d '{ | |
"query": { | |
"match_phrase": { | |
"body.partial_shingle": { | |
"query": "Great Planes Rotor Blade", | |
"analyzer": "analyzer_partial_shingle" | |
} | |
} | |
} | |
} | |
' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment