Created
June 1, 2012 21:03
-
-
Save keerts/2855138 to your computer and use it in GitHub Desktop.
searching with ._all in multi_field
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 'http://localhost:9200/translations/' | |
curl -XPUT 'http://localhost:9200/translations/' -d ' | |
{ | |
"index" : { | |
"name" : "translations", | |
"number_of_shards" : 1, | |
"analysis" : { | |
"analyzer" : { | |
"translation_index_analyzer" : { | |
"type" : "custom", | |
"tokenizer" : "standard", | |
"filter" : "standard,lowercase,translation_tokenizer" | |
}, | |
"translation_search_analyzer" : { | |
"type" : "custom", | |
"tokenizer" : "standard", | |
"filter" : "standard,lowercase" | |
} | |
}, | |
"filter" : { | |
"translation_tokenizer" : { | |
"type" : "nGram", | |
"min_gram" : "1", | |
"max_gram" : "10" | |
} | |
} | |
} | |
} | |
} | |
' | |
curl -XPUT 'http://localhost:9200/translations/translation/_mapping' -d ' | |
{ | |
"type" : { | |
"_source" : { "enabled" : true }, | |
"properties" : { | |
"translation" : { | |
"type" : "multi_field", | |
"fields" : { | |
"translation" : { | |
"type" : "string", | |
"index_analyzer" : "translation_index_analyzer", | |
"search_analyzer" : "translation_search_analyzer" | |
}, | |
"untouched" : { | |
"type" : "string", | |
"search_analyzer" : "translation_search_analyzer" | |
} | |
} | |
}, | |
"localeId" : { | |
"type" : "long" | |
}, | |
"latest" : { | |
"type" : "boolean" | |
} | |
} | |
} | |
} | |
' | |
curl -XPUT 'http://localhost:9200/translations/translation/1' -d '{ "translation": "lorem ipsum" }' | |
curl -XPUT 'http://localhost:9200/translations/translation/2' -d '{ "translation": "Hello world" }' | |
curl -XPUT 'http://localhost:9200/translations/translation/4' -d '{ "translation": "Can you think of a longer word than Hippopotomonstrosesquipedalian" }' | |
curl -XGET 'http://localhost:9200/translations/translation/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"text" : { "translation": "lorem" } | |
} | |
}' | |
curl -XGET 'http://localhost:9200/translations/translation/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"text" : { "translation.untouched": "Hippopotomonstrosesquipedalian" } | |
} | |
}' | |
curl -XGET 'http://localhost:9200/translations/translation/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"text" : { "translation._all": "Hippopotomonstrosesquipedalian" } | |
} | |
}' | |
curl -XGET 'http://localhost:9200/translations/translation/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"text" : { "translation": "quip" } | |
} | |
}' | |
curl -XGET 'http://localhost:9200/translations/translation/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"text" : { "translation._all": "quip" } | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment