Querying "Hash" Values Stored under String Mapping

Hello,

Maybe I'm missing something, because for me it works. Here's what I did:

===================================

curl localhost:9200/testing/test/_mapping?pretty=true

{
"test" : {
"properties" : {
"features" : {
"type" : "string"
}
}
}
}

curl -XPOST localhost:9200/testing/test -d '{

"features": "{\"name\" : \"bob\", \"age\" : \"thirty\"}"

}'
{"ok":true,"_index":"testing","_type":"test","_id":"N974zlY6T6KwSWokv3n-1g","_version":1}

curl http://localhost:9200/testing/test/_search?pretty=true -d '{

"query" : { "text" : { "features" : "age" } } }'
{
<--- REMOVED SOME STUFF HERE --->
"hits" : [ {
"_index" : "testing",
"_type" : "test",
"_id" : "N974zlY6T6KwSWokv3n-1g",
"_score" : 0.15342641, "_source" : {
"features": "{"name" : "bob", "age" : "thirty"}"
}
} ]
}
}

Which version of Elasticsearch are you using?

Best regards,
Radu

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

On Tue, Oct 23, 2012 at 11:32 AM, govind201 govind@semantics3.com wrote:

My index has a field called "features" with mapping type "string" as
follows:

{

"twitter": {

    "user": {

        "properties": {

            "features": {

                "type": "string"

            }

        }

    }

}

}

Here are three examples of potential values that may be stored in
"features":

Example 1: name bob age thirty

Example 2: ["name", "bob", "age", "thirty"]

Example 3: {"name" : "bob", "age" : "thirty"}

The query

curl -XGET http://localhost:9200/twitter/user/_search -d '{ "query" : {
"text" : { "features" : "age" } } }'

returns examples 1 and 2, but not example 3.

The "features" field may contain any number of keys (such as age, name,
fieldX, fieldYZ …) and I want to maintain a strict mapping, hence my choice
of the "string" type mapping. I do, however, want to carry out text searches
along the words, i.e. return example 3 if the query is either "name", "bob",
"age" or "thirty". Is there any query that can return the results I seek?

FYI, running the analyze API along example 3:

curl -XGET "localhost:9200/twitter/_analyze?tokenizer=standard&pretty=true"
-d '{"name" : "bob", "age" : "thirty"}'

seems to tokenize the string as expected into "thirty", "age", "bob" and
"name".

Thanks!

--