Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl -XPUT 'http://localhost:9200/test_attribs?pretty' -d '{
- "settings": {
- "analysis": {
- "analyzer": {
- "ngram_analyzer": {
- "filter": [
- "lowercase",
- "asciifolding",
- "ngram_filter"
- ],
- "tokenizer": "whitespace",
- "type": "custom"
- },
- "searchterm_analyzer": {
- "filter": [
- "lowercase",
- "asciifolding"
- ],
- "tokenizer": "whitespace",
- "type": "custom"
- }
- },
- "filter": {
- "ngram_filter": {
- "max_gram": 30,
- "min_gram": 3,
- "token_chars": [
- "letter",
- "digit",
- "punctuation",
- "symbol"
- ],
- "type": "edgeNGram"
- }
- }
- },
- "number_of_replicas": 0,
- "number_of_shards": 5
- }
- }'
- curl -XPUT 'http://localhost:9200/test_attribs/_mapping/prodgroup_with_attribs_test?pretty' -d '{
- "prodgroup_with_attribs_test": {
- "dynamic": "strict",
- "properties": {
- "Color": {
- "index": "not_analyzed",
- "search_analyzer": "searchterm_analyzer",
- "type": "string"
- },
- "attributes": {
- "properties": {
- "key": {
- "index": "not_analyzed",
- "type": "string"
- },
- "value": {
- "index": "not_analyzed",
- "type": "string"
- }
- },
- "type": "nested"
- },
- "prodno": {
- "index_analyzer": "ngram_analyzer",
- "search_analyzer": "searchterm_analyzer",
- "type": "string"
- },
- "zoom": {
- "index": "not_analyzed",
- "search_analyzer": "searchterm_analyzer",
- "type": "string"
- }
- }
- }
- }'
- curl -XPUT 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/WEBC2590?pretty' -d '{
- "Color": [
- "Blue"
- ],
- "attributes": [
- {
- "key": "Color",
- "value": [
- "Black",
- "Blue",
- "Teal"
- ]
- },
- {
- "key": "Type",
- "value": [
- "Autoclavable"
- ]
- },
- {
- "key": "Amount of Holes",
- "value": [
- "10",
- "15",
- "27"
- ]
- },
- {
- "key": "Hole Configuration",
- "value": [
- "FG",
- "FG/Latch",
- "Latch"
- ]
- }
- ],
- "prodno": [
- "9590062",
- "9590066",
- "9590070",
- "9590064",
- "9590078",
- "9590082",
- "9590050"
- ],
- "zoom": [
- "autoclavable"
- ]
- }'
- curl -XGET 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/_search?pretty' -d '{
- "query": {
- "filtered": {
- "filter": {
- "nested": {
- "filter": {
- "bool": {
- "must": [
- {
- "bool": {
- "must": [
- {
- "term": {
- "attributes.key": "Color"
- }
- },
- {
- "terms": {
- "attributes.value": [
- "Blue"
- ]
- }
- }
- ]
- }
- }
- ]
- }
- },
- "path": "attributes"
- }
- }
- }
- },
- "size": 20
- }'
- curl -XGET 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/_search?pretty' -d '{
- "query": {
- "filtered": {
- "filter": {
- "nested": {
- "filter": {
- "bool": {
- "must": [
- {
- "bool": {
- "must": [
- {
- "term": {
- "attributes.key": "Type"
- }
- },
- {
- "terms": {
- "attributes.value": [
- "Autoclavable"
- ]
- }
- }
- ]
- }
- }
- ]
- }
- },
- "path": "attributes"
- }
- }
- }
- },
- "size": 20
- }'
- curl -XGET 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/_search?pretty' -d '{
- "query": {
- "filtered": {
- "filter": {
- "nested": {
- "filter": {
- "bool": {
- "must": [
- {
- "bool": {
- "must": [
- {
- "term": {
- "attributes.key": "Color"
- }
- },
- {
- "terms": {
- "attributes.value": [
- "Blue"
- ]
- }
- }
- ]
- }
- },
- {
- "bool": {
- "must": [
- {
- "term": {
- "attributes.key": "Type"
- }
- },
- {
- "terms": {
- "attributes.value": [
- "Autoclavable"
- ]
- }
- }
- ]
- }
- }
- ]
- }
- },
- "path": "attributes"
- }
- }
- }
- },
- "size": 20
- }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement