Hello,
I think I understand now. So if your mapping is string, like this:
"test" : {
"properties" : {
"foo" : {
"type" : "string"
}
}
}
And if you index an unescaped JSON, like this:
curl -XPUT localhost:9200/test/test/111 -d '{"foo":{"bar":"baz"}}'
You should end up only with the words, like this:
"_source" : {"foo":"bar baz"}
So your field names within the string, like "bar" in the example
above, would show up in a match query, like this:
curl -XPOST localhost:9200/test/test/_search?pretty=true -d '{
"query": {
"match": {
"foo": "bar"
}
}
}'
Best regards,
Radu
http://sematext.com/ -- Elasticsearch -- Solr -- Lucene
On Wed, Oct 24, 2012 at 8:23 PM, govind201 govind@semantics3.com wrote:
Hi Radu,
I didn't get the results expected for any of the queries that you mentioned.
I even upgraded from 0.19.8 to 0.19.11 just in case. That query behavior
seems logical for your standard case, but in my case, the mapping is of type
"string", as I'd mentioned:{
"twitter": { "user": { "properties": { "features": { "type": "string" } } } }}
On Wednesday, October 24, 2012 10:02:39 PM UTC+8, Radu Gheorghe wrote:
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,
Raduhttp://sematext.com/ -- Elasticsearch -- Solr -- Lucene
On Wed, Oct 24, 2012 at 12:27 PM, govind201 gov...@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.
--
--
--