Nested text phrase query


(Ben McCann) #1

I can create a query for a nested field on the command line and get the
result I expected:
http://localhost:9200/connectifier/conn/_search?q=phoneNumbers.canonical:12533813364

However, I'm not sure how to do this with the Java client. I tried the
following and got back zero results:
SearchRequest request = new SearchRequest("connectifier")
.types("conn")
.source(new SearchSourceBuilder()
.query(QueryBuilders.textPhraseQuery("phoneNumbers.canonical",
"12533813364")));

Is this not how you represent a nested field from the Java client?

Thanks,
Ben


(Ben McCann) #2

Nevermind, stupid mistake on my end. The code I wrote here does work.

On Tuesday, April 10, 2012 4:46:00 PM UTC-7, Ben McCann wrote:

I can create a query for a nested field on the command line and get the
result I expected:

http://localhost:9200/connectifier/conn/_search?q=phoneNumbers.canonical:12533813364

However, I'm not sure how to do this with the Java client. I tried the
following and got back zero results:
SearchRequest request = new SearchRequest("connectifier")
.types("conn")
.source(new SearchSourceBuilder()
.query(QueryBuilders.textPhraseQuery("phoneNumbers.canonical",
"12533813364")));

Is this not how you represent a nested field from the Java client?

Thanks,
Ben


(system) #3