Search JAVA search API not working


(Mohit Anchlia) #1

The below code doesn't seem to match the document for some reason. Same
query when run directly using REST API works. Am I doing something wrong in
the code?

queryString="fields.field1:value1";

searchResponse = client.prepareSearch()
.setQuery(QueryBuilders.queryString(queryString)).execute()
.actionGet();

Doc that I expect to match
'{
"namespace": "ns1",
"id": "3",
"fastId": "f1",
"version": 1393443298027,
"lang": "en",
"opType": "create",
"fields": {
"field2": "value2",
"field1": "value1"
},
"arrayFields": {}
}'

--
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/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #2

Are you just searching in your code or indexing as well?
Could it be caused because you did not refresh before searching?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 mars 2014 à 22:13, Mohit Anchlia mohitanchlia@gmail.com a écrit :

The below code doesn't seem to match the document for some reason. Same query when run directly using REST API works. Am I doing something wrong in the code?

queryString="fields.field1:value1";

		searchResponse = client.prepareSearch()
				.setQuery(QueryBuilders.queryString(queryString)).execute()
				.actionGet();

Doc that I expect to match
'{
"namespace": "ns1",
"id": "3",
"fastId": "f1",
"version": 1393443298027,
"lang": "en",
"opType": "create",
"fields": {
"field2": "value2",
"field1": "value1"
},
"arrayFields": {}
}'

--
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/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/0772CCDA-1515-4B40-8808-FA701E358327%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(Mohit Anchlia) #3

oh, I forgot refresh. Let me try that. By default it's 1 sec right?

On Fri, Mar 21, 2014 at 2:18 PM, David Pilato david@pilato.fr wrote:

Are you just searching in your code or indexing as well?
Could it be caused because you did not refresh before searching?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 mars 2014 à 22:13, Mohit Anchlia mohitanchlia@gmail.com a écrit :

The below code doesn't seem to match the document for some reason. Same
query when run directly using REST API works. Am I doing something wrong in
the code?

queryString="fields.field1:value1";

searchResponse = client.prepareSearch()
.setQuery(QueryBuilders.queryString(queryString)).execute()
.actionGet();

Doc that I expect to match
'{
"namespace": "ns1",
"id": "3",
"fastId": "f1",
"version": 1393443298027,
"lang": "en",
"opType": "create",
"fields": {
"field2": "value2",
"field1": "value1"
},
"arrayFields": {}
}'

--
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/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.comhttps://groups.google.com/d/msgid/elasticsearch/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/0772CCDA-1515-4B40-8808-FA701E358327%40pilato.frhttps://groups.google.com/d/msgid/elasticsearch/0772CCDA-1515-4B40-8808-FA701E358327%40pilato.fr?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOT3TWoEuUrsy1j-i_yTcQxoRyCR-nsYyDTQwvw_QT-6dsYTnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Mohit Anchlia) #4

Thanks! refresh was the issue. Is there a easy way to find how many
documents are in index using Java API?

On Fri, Mar 21, 2014 at 2:24 PM, Mohit Anchlia mohitanchlia@gmail.comwrote:

oh, I forgot refresh. Let me try that. By default it's 1 sec right?

On Fri, Mar 21, 2014 at 2:18 PM, David Pilato david@pilato.fr wrote:

Are you just searching in your code or indexing as well?
Could it be caused because you did not refresh before searching?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 mars 2014 à 22:13, Mohit Anchlia mohitanchlia@gmail.com a écrit :

The below code doesn't seem to match the document for some reason. Same
query when run directly using REST API works. Am I doing something wrong in
the code?

queryString="fields.field1:value1";

searchResponse = client.prepareSearch()
.setQuery(QueryBuilders.queryString(queryString)).execute()
.actionGet();

Doc that I expect to match
'{
"namespace": "ns1",
"id": "3",
"fastId": "f1",
"version": 1393443298027,
"lang": "en",
"opType": "create",
"fields": {
"field2": "value2",
"field1": "value1"
},
"arrayFields": {}
}'

--
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/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.comhttps://groups.google.com/d/msgid/elasticsearch/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/0772CCDA-1515-4B40-8808-FA701E358327%40pilato.frhttps://groups.google.com/d/msgid/elasticsearch/0772CCDA-1515-4B40-8808-FA701E358327%40pilato.fr?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOT3TWoev84CMWigQJMkBEaW_KsGpYc%2BWCA9qaHPQxXUt2sr8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #5

client.prepareCount()

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 mars 2014 à 22:34, Mohit Anchlia mohitanchlia@gmail.com a écrit :

Thanks! refresh was the issue. Is there a easy way to find how many documents are in index using Java API?

On Fri, Mar 21, 2014 at 2:24 PM, Mohit Anchlia mohitanchlia@gmail.com wrote:
oh, I forgot refresh. Let me try that. By default it's 1 sec right?

On Fri, Mar 21, 2014 at 2:18 PM, David Pilato david@pilato.fr wrote:
Are you just searching in your code or indexing as well?
Could it be caused because you did not refresh before searching?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 mars 2014 à 22:13, Mohit Anchlia mohitanchlia@gmail.com a écrit :

The below code doesn't seem to match the document for some reason. Same query when run directly using REST API works. Am I doing something wrong in the code?

queryString="fields.field1:value1";

  	searchResponse = client.prepareSearch()
  			.setQuery(QueryBuilders.queryString(queryString)).execute()
  			.actionGet();

Doc that I expect to match
'{
"namespace": "ns1",
"id": "3",
"fastId": "f1",
"version": 1393443298027,
"lang": "en",
"opType": "create",
"fields": {
"field2": "value2",
"field1": "value1"
},
"arrayFields": {}
}'

--
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/CAOT3TWoSGTpNQpHBUUNpa0qQr0X8rm7pZXoqxYqcb-349xkrmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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/0772CCDA-1515-4B40-8808-FA701E358327%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOT3TWoev84CMWigQJMkBEaW_KsGpYc%2BWCA9qaHPQxXUt2sr8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/BC821437-7504-46BB-9F24-1B0DC42F086D%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(system) #6