Created
July 30, 2013 02:01
-
-
Save anonymous/6109593 to your computer and use it in GitHub Desktop.
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
echo "Deleting old ElasticSearch index..." | |
curl -XDELETE 'localhost:9200/arrtest' | |
echo "Creating new ElasticSearch index..." | |
curl -XPUT 'localhost:9200/arrtest/?pretty=1' -d ' | |
{ | |
"mappings" : { | |
"cust2" : { | |
"properties" : { | |
"firstName" : { | |
"type" : "string", | |
"analyzer" : "string_lowercase" | |
}, | |
"lastName" : { | |
"type" : "string", | |
"analyzer" : "string_lowercase" | |
}, | |
"paymentInfos": { | |
"properties": { | |
"billingZip": { | |
"type": "string", | |
"analyzer": "string_lowercase" | |
}, | |
"paypalEmail": { | |
"type": "string", | |
"analyzer": "string_lowercase" | |
} | |
}, | |
"type": "nested" | |
} | |
} | |
} | |
}, | |
"settings" : { | |
"analysis" : { | |
"analyzer" : { | |
"uax_url_email" : { | |
"filter" : [ "standard", "lowercase" ], | |
"tokenizer" : "uax_url_email" | |
}, | |
"string_lowercase": { | |
"tokenizer" : "keyword", | |
"filter" : "lowercase" | |
} | |
} | |
} | |
} | |
} | |
' | |
echo "Index recreation finished" | |
echo "Inserting one record..." | |
curl -XPUT 'localhost:9200/arrtest/cust2/1' -d ' | |
{ | |
"firstName" : "john", | |
"lastName" : "smith", | |
"paymentInfos": [ | |
{ | |
"billingZip": "10101", | |
"paypalEmail": "[email protected]" | |
}, | |
{ | |
"billingZip": "20202", | |
"paypalEmail": "[email protected]" | |
} | |
] | |
}' | |
echo "Searching for record..." | |
curl -XGET 'localhost:9200/arrtest/cust2/_search?pretty=1' -d ' | |
{ | |
"sort": [], | |
"query": { | |
"bool": { | |
"should": [], | |
"must_not": [], | |
"must": [ | |
{ | |
"query_string": { | |
"fields": [ | |
"paymentInfos.billingZip" | |
], | |
"query": "10101" | |
} | |
} | |
] | |
} | |
}, | |
"facets": {}, | |
"from": 0, | |
"size": 25 | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment