Created
September 24, 2015 08:01
-
-
Save Alino/4f7a80ee63012275605e to your computer and use it in GitHub Desktop.
How to filter out elements from an array that doesn’t match the query?
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
POST /products | |
{ | |
"settings": { | |
"analysis": { | |
"filter": { | |
"nGram_filter": { | |
"type": "nGram", | |
"min_gram": 2, | |
"max_gram": 20, | |
"token_chars": [ | |
"letter", | |
"digit", | |
"punctuation", | |
"symbol" | |
] | |
} | |
}, | |
"analyzer": { | |
"nGram_analyzer": { | |
"type": "custom", | |
"tokenizer": "whitespace", | |
"filter": [ | |
"lowercase", | |
"asciifolding", | |
"nGram_filter" | |
] | |
} | |
} | |
} | |
} | |
} |
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
POST /products/paramSuggestions/_mapping | |
{ | |
"properties": { | |
"productName": { | |
"type": "string" | |
}, | |
"params": { | |
"properties": { | |
"paramName": { | |
"type": "string", | |
"analyzer": "nGram_analyzer" | |
}, | |
"value": { | |
"type": "string", | |
"analyzer": "nGram_analyzer" | |
} | |
} | |
} | |
} | |
} |
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
POST /products/paramSuggestions/1 | |
{ | |
"productName": "iphone 6", | |
"params": [ | |
{ | |
"paramName": "color", | |
"value": "white" | |
}, | |
{ | |
"paramName": "capacity", | |
"value": "32GB" | |
} | |
] | |
} |
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
GET products/paramSuggestions/_search | |
{ | |
"size": 10, | |
"query": { | |
"filtered": { | |
"query": { | |
"match": { | |
"paramName": { | |
"query": "col", | |
"operator": "and" | |
} | |
} | |
} | |
} | |
} | |
} |
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": 2, | |
"timed_out": false, | |
"_shards": { | |
"total": 5, | |
"successful": 5, | |
"failed": 0 | |
}, | |
"hits": { | |
"total": 1, | |
"max_score": 0.33217794, | |
"hits": [ | |
{ | |
"_index": "products", | |
"_type": "paramSuggestions", | |
"_id": "1", | |
"_score": 0.33217794, | |
"_source": { | |
"productName": "iphone 6", | |
"params": [ | |
{ | |
"paramName": "color", | |
"value": "white" | |
}, | |
{ | |
"paramName": "capacity", | |
"value": "32GB" | |
} | |
] | |
} | |
} | |
] | |
} | |
} |
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": 2, | |
"timed_out": false, | |
"_shards": { | |
"total": 5, | |
"successful": 5, | |
"failed": 0 | |
}, | |
"hits": { | |
"total": 1, | |
"max_score": 0.33217794, | |
"hits": [ | |
{ | |
"_index": "products", | |
"_type": "paramSuggestions", | |
"_id": "1", | |
"_score": 0.33217794, | |
"_source": { | |
"productName": "iphone 6", | |
"params": [ | |
{ | |
"paramName": "color", | |
"value": "white" | |
}, | |
] | |
} | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment