That's exactly the behavior that I'd sought. But the query doesn't work as
you describe it, i.e., it returns no hits. Try these one after the other
and you'll see:
curl -XPUT localhost:9200/test
curl -XPUT 'localhost:9200/test/test/_mapping' -d ' { "test" : {
"properties" : { "foo" : {"type" : "string"} } } } '
curl -XPUT localhost:9200/test/test/2 -d '{"foo":{"bar":"baz"}}'
curl -XPOST localhost:9200/test/test/_search?pretty=true -d '{ "query": {
"match": { "foo": "bar" } } }'
I can't seem to retrieve document 2 for any sort of match query. It is,
however, returned when I execute:
curl -XPOST localhost:9200/test/test/_search?pretty=true
On Thursday, October 25, 2012 4:25:14 AM UTC+8, Radu Gheorghe wrote:
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,
Raduhttp://sematext.com/ -- Elasticsearch -- Solr -- Lucene
On Wed, Oct 24, 2012 at 8:23 PM, govind201 <gov...@semantics3.com<javascript:>>
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.
--
--
--