I've loaded the 'accounts.json' data from the following link into an ES instance on my machine:
https://www.elastic.co/guide/en/elasticsearch/reference/1.5/_exploring_your_data.html
This adds 1000 docs to the index 'bank' with the type 'account'. Simple enough!
Every doc has this structure:
{
"account_number": 0,
"balance": 16623,
"firstname": "Bradshaw",
"lastname": "Mckenzie",
"age": 29,
"gender": "F",
"address": "244 Columbus Place",
"employer": "Euron",
"email": "[email protected]",
"city": "Hobucken",
"state": "CO"
}
Now I'm trying to run a simple 'prefix' query on this index.
Here is one that works just fine (comes back with plenty of correct results):
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"query": { "prefix" : { "address" : "963" } }
}'
Here is another one (this one doesn't work):
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"query": { "prefix" : { "firstname" : "Op" } }
}'
But there is definitely a record present which should be returned in the previous request. The following works:
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"query": { "match" : { "firstname" : "Opal" } }
}'
I have also verified the mapping and there doesn't seem to be any difference in the 2 fields, 'firstname' and 'address':
curl -XGET 'localhost:9200/bank/_mapping/account?pretty'
Here is the relevant mapping portion for those 2:
"address": {
"type": "string"
}
"firstname": {
"type": "string"
}
Can't figure out why one prefix query works and the other one doesn't. Any pointers on what I'm missing?