Querying "Hash" Values Stored under String Mapping

Hello,

Now that "name" and "age" are fields, you can either query for the
content of those fields, like:

curl localhost:9200/twitter/user/_search?pretty=true -d '{
"query": {
"match": {
"features.age": "thirty"
}
}
}'

By default, they're included in _all, so they would appear in this as
well, but you might get unwanted results from other fields:

curl localhost:9200/twitter/user/_search?pretty=true -d '{
"query": {
"match": {
"_all": "thirty"
}
}
}'

And you can also check for the existence of fields like "age" with filters:

curl localhost:9200/twitter/user/_search?pretty=true -d '{
"query": {
"constant_score" : {
"filter" : {
"exists" : { "field" : "features.age" }
}
}
}
}'

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 24, 2012 at 12:27 PM, govind201 govind@semantics3.com wrote:

Right, so is there any way at all to query the text now, even if it be by
age or name ("features.age"/"features.name" don't work)? After all, mapping
for the field is of type "string".

On Wednesday, October 24, 2012 5:00:07 PM UTC+8, Zhibin wrote:

{
"_id": "2",
"_index": "insta",
"_score": 1.0,
"_source": {
"features": {
"age": "thirty",
"name": "bob"
}
},
"_type": "user"
},

As you did not escape the quotation marks, the parser reads as it under
features, {field=age, value=thirty}, {field=name, value=bob}.
Your text search is looking for value of "age", thus will not match as it
is a field name.

Note in 0.19.9, text query is renamed to match query.

--

--