Basic fuzzy query is broken after bulk document indexing?


(canuck3141) #1

Hi,

I can't get fuzzy search to work and I'm not sure if it's a bug in ElasticSearch or a bug in my understanding of its syntax.

I do the following:

curl -XPUT "http://localhost:9200/test?pretty=true" -d '
{
"mappings" : {
"member" : {
"properties" : { "first_name" : { "type" : "string" }, "last_name" : { "type" : "string" } }
}
}
}
'

Returns 200, success!

Then I bulk-insert some members:

curl -XPOST "http://localhost:9200/_bulk?pretty=true" -d '
{"index" : {"_index" : "test", "_type" : "member"}}
{ "first_name" : "Robert", "last_name" : "Johnson" }
{"index" : {"_index" : "test", "_type" : "member"}}
{ "first_name" : "Elvis", "last_name" : "Presley" }
'

Returns 200, success!

Now I can do a simple search and it works fine:

curl "http://localhost:9200/test/member/_search?pretty=true&q=robert"

Returns 200 success and body:

{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.13561106,
"hits" : [ {
"_index" : "test",
"_type" : "member",
"_id" : "qhwVNX6PTNupID0jl07Vzw",
"_score" : 0.13561106, "_source" : { "first_name" : "Robert", "last_name" : "Johnson" }
} ]
}
}

BUT FUZZY SEARCH ALWAYS FAILS:

curl -XGET "http://localhost:9200/test/member/_search?pretty=true" -d '
{
"query" : {
"fuzzy" : { "first_name" : "Robart" }
}
}
'

Returns 500, failure:

{
"error" : "ActionRequestValidationException[Validation Failed: 1: search source is missing;]",
"status" : 500
}

What does "search source is missing" mean?

How can I make a basic fuzzy search work? I don't want to use the '~', I want to use "fuzzy" and I am following the guide here http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.html but it doesn't seem to work.

Am I just totally misunderstanding the syntax for specifying the fuzzy query or what?

Any help is hugely appreciated!

Thanks.


(canuck3141) #2

Anybody? Any ideas?


(Shay Banon) #3

The failure means that for some reason the search body request did not pass
to elasticsearch.

On Thu, Nov 17, 2011 at 8:24 PM, canuck3141 canuck3141@gmail.com wrote:

Hi,

I can't get fuzzy search to work and I'm not sure if it's a bug in
ElasticSearch or a bug in my understanding of its syntax.

I do the following:

curl -XPUT "http://localhost:9200/test?pretty=true" -d '
{
"mappings" : {
"member" : {
"properties" : { "first_name" : { "type" : "string" }, "last_name" :
{ "type" : "string" } }
}
}
}
'

Returns 200, success!

Then I bulk-insert some members:

curl -XPOST "http://localhost:9200/_bulk?pretty=true" -d '
{"index" : {"_index" : "test", "_type" : "member"}}
{ "first_name" : "Robert", "last_name" : "Johnson" }
{"index" : {"_index" : "test", "_type" : "member"}}
{ "first_name" : "Elvis", "last_name" : "Presley" }
'

Returns 200, success!

Now I can do a simple search and it works fine:

curl "http://localhost:9200/test/member/_search?pretty=true&q=robert"

Returns 200 success and body:

{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.13561106,
"hits" : [ {
"_index" : "test",
"_type" : "member",
"_id" : "qhwVNX6PTNupID0jl07Vzw",
"_score" : 0.13561106, "_source" : { "first_name" : "Robert",
"last_name" : "Johnson" }
} ]
}
}

BUT FUZZY SEARCH ALWAYS FAILS:

curl -XGET "http://localhost:9200/test/member/_search?pretty=true" -d '
{
"query" : {
"fuzzy" : { "first_name" : "Robart" }
}
}
'

Returns 500, failure:

{
"error" : "ActionRequestValidationException[Validation Failed: 1: search
source is missing;]",
"status" : 500
}

What does "search source is missing" mean?

How can I make a basic fuzzy search work? I don't want to use the '~', I
want to use "fuzzy" and I am following the guide here
http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.htmlbut
it doesn't seem to work.

Am I just totally misunderstanding the syntax for specifying the fuzzy
query
or what?

Any help is hugely appreciated!

Thanks.

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Basic-fuzzy-query-is-broken-after-bulk-document-indexing-tp3516614p3516614.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(system) #4