Created
June 21, 2012 13:41
-
-
Save dadoonet/2965777 to your computer and use it in GitHub Desktop.
Test case for multifield fields
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
# Remove old data | |
curl -XDELETE "http://localhost:9200/french" | |
# Create index with settings | |
curl -XPOST "http://localhost:9200/french/" -d ' | |
{ | |
"settings":{ | |
"index":{ | |
"analysis":{ | |
"analyzer":{ | |
"email":{ | |
"type":"custom", | |
"tokenizer":"uax_url_email" | |
}, | |
"french":{ | |
"type":"custom", | |
"tokenizer":"standard", | |
"filter":[ | |
"lowercase", | |
"stop_fr", | |
"fr_stemmer", | |
"asciifolding" | |
] | |
} | |
}, | |
"filter":{ | |
"stop_fr":{ | |
"type":"stop", | |
"stopwords":[ | |
"_french_" | |
] | |
}, | |
"fr_stemmer":{ | |
"type":"stemmer", | |
"name":"french" | |
}, | |
"elision":{ | |
"type":"elision", | |
"articles":[ | |
"l", | |
"m", | |
"t", | |
"qu", | |
"n", | |
"s", | |
"j", | |
"d" | |
] | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
# Define mapping | |
curl -XPOST "http://localhost:9200/french/user/_mapping" -d ' | |
{ | |
"user":{ | |
"_all":{ | |
"analyzer":"french" | |
}, | |
"properties":{ | |
"email":{ | |
"type":"multi_field", | |
"fields":{ | |
"email":{ | |
"type":"string", | |
"index":"analyzed", | |
"analyzer":"email" | |
}, | |
"untouched":{ | |
"type":"string", | |
"index":"not_analyzed" | |
} | |
} | |
}, | |
"test":{ | |
"type":"string", | |
"analyzer":"french" | |
}, | |
"password":{ | |
"type":"string", | |
"index":"not_analyzed" | |
}, | |
"last_name":{ | |
"type":"multi_field", | |
"fields":{ | |
"last_name":{ | |
"type":"string", | |
"index":"analyzed", | |
"analyzer":"french" | |
}, | |
"untouched":{ | |
"type":"string", | |
"index":"not_analyzed" | |
} | |
} | |
}, | |
"first_name":{ | |
"type":"multi_field", | |
"fields":{ | |
"first_name":{ | |
"type":"string", | |
"index":"analyzed", | |
"analyzer":"french" | |
}, | |
"untouched":{ | |
"type":"string", | |
"index":"not_analyzed" | |
} | |
} | |
}, | |
"birthday":{ | |
"type":"date", | |
"format":"date" | |
}, | |
"date_creation":{ | |
"type":"date", | |
"format":"yyyy-MM-dd HH:mm:ss" | |
}, | |
"date_activation":{ | |
"type":"date", | |
"format":"yyyy-MM-dd HH:mm:ss", | |
"null_value":"0000-00-00 00:00:00" | |
}, | |
"key_activation":{ | |
"type":"string", | |
"index":"not_analyzed", | |
"null_value":"" | |
}, | |
"key_password":{ | |
"type":"string", | |
"index":"not_analyzed", | |
"null_value":"" | |
}, | |
"activate":{ | |
"type":"boolean", | |
"null_value":1 | |
}, | |
"type_permission":{ | |
"type":"multi_field", | |
"fields":{ | |
"type_permission":{ | |
"type":"string", | |
"index":"analyzed", | |
"analyzer":"french", | |
"null_value":"user" | |
}, | |
"untouched":{ | |
"type":"string", | |
"index":"not_analyzed", | |
"null_value":"user" | |
} | |
} | |
}, | |
"permissions":{ | |
"type":"string", | |
"index":"not_analyzed", | |
"null_value":"" | |
} | |
} | |
} | |
} | |
' | |
# Create Document | |
curl -XPOST "http://localhost:9200/french/user/" -d ' | |
{ | |
"email":"[email protected]", | |
"test":"Clé", | |
"birthday":"1988-04-24", | |
"date_creation":"2012-06-21 05:46:59", | |
"first_name":"Gégé", | |
"last_name":"Mémé", | |
"password":"f5ab96926a6a561aab7ecb4ba7c915d4", | |
"type_permission":"" | |
} | |
' | |
# Wait for ES to be synced (aka refresh indices) | |
curl -XPOST "http://localhost:9200/french/_refresh" | |
# Search | |
curl -XPOST "http://localhost:9200/french/user/_search?pretty=true" -d ' | |
{ | |
"query":{ | |
"term":{ | |
"first_name.untouched":"Gégé" | |
} | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment