ES 1.2.1 difference in search result between Java clients and REST

I am updating a project to store metadata in ES for enhanced searching. The
server is currently fixed to ES 1.2.1.

Locally, I have a ES node with the Marvel plugin so I can access the sense
editor to run queries. I have a unit test that is populating data into ES.
The data is formatted such as

        "_source": {
           "protocol": "my-protocol",
           "right": "my-right",
           "type": "my-type",
           "address": [
              "my-hostname"
           ]
        }

My goal is to build a query that will search for multiple addresses that
are all optional; think of it as the various IPs and names associated with
a single server.

In Java, I am building a set of match queries that are joined with boolean
should. Here is some of the code.

        Set<String> addresses = findHostAddresses(criteria.getHost());
        BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery(); 

        for (String address : addresses) 
        { 
            boolBuilder.should(QueryBuilders.matchQuery(

CredentialManagerSearchConstants.FIELD_ADDRESS, address.toLowerCase()));
}

This is then wrapped once more with a boolean must query clause to find a
specific result based on address and one or more of the other fields. If I
look at the constructed query in my debugger, the query looks like the
following.

"bool" : {
"must" : {
"bool" : {
"should" : [ {
"match" : {
"address" : {
"query" : "host1",
"type" : "boolean"
}
}
},{
"match" : {
"address" : {
"query" : "host2",
"type" : "boolean"
}
}
} ]
}
}
}

I use a SearchRequestBuilder and set my index, type and the noFields flag
(I don't need the data, just the ID). For my simple case, I know that I
have a record with a particular address in it. If I search for a single
address only using a single match, the Java bindings work correctly. If I
search for multiple addresses like the above, then the result is not found.

I thought this may just be a problem with how I am constructing the query.
I took the output from my debugger on the query itself and used the marvel
sense plugin to execute that exact query through the REST API. Here is an
example of the query from marvel sense.

GET /my-index/my-type/_search
{
"query": {
"bool": {
"must": {
"bool": {
"should": [
{
"match": {
"address": {
"query": "host1",
"type": "boolean"
}
}
},
{
"match": {
"address": {
"query": "host2",
"type": "boolean"
}
}
}
]
}
}
}
}
}

Using the REST API, the one document that I have in my sample indexed
document set is returned without issue.

It is entirely possible that I am using the Java APIs incorrectly. The
documentation for these APIs is not always that useful.

Are there any reports of the native or transport protocols behaving
differently than the REST protocol? That appears to be what is happening
here.

As a test, I ran the latest 1.3 and 1.4 versions of ES through my unit
tests and the behavior is still the same in those versions.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/688fdc29-07f6-4073-b6da-bbc58fde6419%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I noticed that we were using Spring Data Elastic Search (1.1.0) to create
the node or transport objects for us. It allows us to build it with
configuration instead of code. Just in case that was causing a problem, in
my search code, I constructed a Transport object directly and use that
instead of the one built by Spring Data Elastic Search. There is no
difference in behavior.

I also took out the setNoFields() call when building the search without any
other differences either.

On Wednesday, February 4, 2015 at 1:37:39 PM UTC-5, Josh Bonczkowski wrote:

I am updating a project to store metadata in ES for enhanced searching.
The server is currently fixed to ES 1.2.1.

Locally, I have a ES node with the Marvel plugin so I can access the sense
editor to run queries. I have a unit test that is populating data into ES.
The data is formatted such as

        "_source": {
           "protocol": "my-protocol",
           "right": "my-right",
           "type": "my-type",
           "address": [
              "my-hostname"
           ]
        }

My goal is to build a query that will search for multiple addresses that
are all optional; think of it as the various IPs and names associated with
a single server.

In Java, I am building a set of match queries that are joined with boolean
should. Here is some of the code.

        Set<String> addresses = findHostAddresses(criteria.getHost());
        BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery(); 

        for (String address : addresses) 
        { 
            boolBuilder.should(QueryBuilders.matchQuery(

CredentialManagerSearchConstants.FIELD_ADDRESS, address.toLowerCase()));
}

This is then wrapped once more with a boolean must query clause to find a
specific result based on address and one or more of the other fields. If I
look at the constructed query in my debugger, the query looks like the
following.

"bool" : {
"must" : {
"bool" : {
"should" : [ {
"match" : {
"address" : {
"query" : "host1",
"type" : "boolean"
}
}
},{
"match" : {
"address" : {
"query" : "host2",
"type" : "boolean"
}
}
} ]
}
}
}

I use a SearchRequestBuilder and set my index, type and the noFields flag
(I don't need the data, just the ID). For my simple case, I know that I
have a record with a particular address in it. If I search for a single
address only using a single match, the Java bindings work correctly. If I
search for multiple addresses like the above, then the result is not found.

I thought this may just be a problem with how I am constructing the query.
I took the output from my debugger on the query itself and used the marvel
sense plugin to execute that exact query through the REST API. Here is an
example of the query from marvel sense.

GET /my-index/my-type/_search
{
"query": {
"bool": {
"must": {
"bool": {
"should": [
{
"match": {
"address": {
"query": "host1",
"type": "boolean"
}
}
},
{
"match": {
"address": {
"query": "host2",
"type": "boolean"
}
}
}
]
}
}
}
}
}

Using the REST API, the one document that I have in my sample indexed
document set is returned without issue.

It is entirely possible that I am using the Java APIs incorrectly. The
documentation for these APIs is not always that useful.

Are there any reports of the native or transport protocols behaving
differently than the REST protocol? That appears to be what is happening
here.

As a test, I ran the latest 1.3 and 1.4 versions of ES through my unit
tests and the behavior is still the same in those versions.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d47ae046-3e3d-4796-b4f6-595249347f98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

For my own sanity, I have started to build a sample project with minimal
dependencies to reproduce this behavior. So far, I can reproduce it. Of
course, that is just as annoying :slight_smile:

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3fb3616e-8ac0-47f7-84cb-e6e4558427c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cannot reproduce. Apparently I cannot type either. Sorry about that. I
don't see an edit button.

On Wednesday, February 4, 2015 at 7:47:25 PM UTC-5, Josh Bonczkowski wrote:

For my own sanity, I have started to build a sample project with minimal
dependencies to reproduce this behavior. So far, I can reproduce it. Of
course, that is just as annoying :slight_smile:

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e23e3b55-4a20-4df7-bf36-4e64f3e96990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.