Querying "Hash" Values Stored under String Mapping

On Tuesday, October 23, 2012 10:32:09 AM UTC+2, govind201 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"}

hey, are you escaping the hash correctly? it should be astring value right?

simon

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!

--