Java API


(Slava G ) #1

Hi,
I'm a newbie in the elasticsearch and trying to make simple test,
create an index and the search for it, but i get 0 hits, here the
sample:

Node node = nodeBuilder().client(true).node();
		Client client = node.client();
		IndexResponse indexRes = client.prepareIndex("test", "contacts",

"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test_Name")
.field("BirthDate", new Date())
.field("Email", "test@test.com")
.endObject()).execute().actionGet();

		SearchRequestBuilder searchRequestBuilder =

client.prepareSearch("test");
searchRequestBuilder.setTypes("contacts");

searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
searchRequestBuilder.setQuery(termQuery("Name", "Test_Name"));
searchRequestBuilder.setFrom(0).setSize(60).setExplain(true);
SearchResponse response =
searchRequestBuilder.execute().actionGet();

                  node.close();

Please , tell me what I'm doing wrong.

Thank You and Best Regards.
Slava.


(dpilato) #2

Test_Name has been tokenized to Test and Name.
So, searching Test_Name can not work.

You should search test or name to find something.

Hope this helps,
David


(Slava G ) #3

Changed to "Test" - same result - 0 hits:

Node node = nodeBuilder().client(true).node();
Client client = node.client();
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "test@test.com")
.endObject()
)
.execute()
.actionGet();

		SearchRequestBuilder searchRequestBuilder =

client.prepareSearch("test");
//searchRequestBuilder.setTypes("contacts");

searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
searchRequestBuilder.setQuery(termQuery("Name", "Test"));
searchRequestBuilder.setFrom(0).setSize(60).setExplain(false);
SearchResponse response =
searchRequestBuilder.execute().actionGet();

		node.close();

Thank You and Best Regards.

On May 28, 11:52 pm, dpilato david.pil...@douane.finances.gouv.fr
wrote:

Test_Name has been tokenized to Test and Name.
So, searching Test_Name can not work.

You should search test or name to find something.

Hope this helps,
David

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(dpilato) #4

What about test in lowercase ?


(Slava G ) #5

Cool :slight_smile: 10x it's works,
But is it means that all data should be lower case ? What are the
rules for that ?
Is there any document explains all such restrictions ?

Thank You and Best Regards.

On May 29, 12:09 am, dpilato david.pil...@douane.finances.gouv.fr
wrote:

What about test in lowercase ?

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(dpilato) #6

Term request is case sensitive. querystring query should work.

Here is a good starting URL : http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David


(Shay Banon) #7

Or, better yet in 0.16.1, text queries (though it has a bug in it for the Java API that will be fixed in 0.16.2).

On Sunday, May 29, 2011 at 1:18 AM, dpilato wrote:

Term request is case sensitive. querystring query should work.

Here is a good starting URL :
http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p2997407.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com (http://Nabble.com).


(Slava G ) #8

Thank You, I'll look on it,
Btw, is there any sample for text queries in Java API ?

Thank You.

On May 29, 8:58 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Or, better yet in 0.16.1, text queries (though it has a bug in it for the Java API that will be fixed in 0.16.2).

On Sunday, May 29, 2011 at 1:18 AM, dpilato wrote:

Term request is case sensitive. querystring query should work.

Here is a good starting URL :
http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com (http://Nabble.com).


(Shay Banon) #9

replace QueryBuilders#term with QueryBuilders#text, pretty basic stuff.

On Sunday, May 29, 2011 at 11:02 AM, slavag wrote:

Thank You, I'll look on it,
Btw, is there any sample for text queries in Java API ?

Thank You.

On May 29, 8:58 am, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

Or, better yet in 0.16.1, text queries (though it has a bug in it for the Java API that will be fixed in 0.16.2).

On Sunday, May 29, 2011 at 1:18 AM, dpilato wrote:

Term request is case sensitive. querystring query should work.

Here is a good starting URL :
http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com (http://Nabble.com).


(Slava G ) #10

Thank You.
As I said - started to use elasticsearch last night :slight_smile:

On May 29, 6:01 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

replace QueryBuilders#term with QueryBuilders#text, pretty basic stuff.

On Sunday, May 29, 2011 at 11:02 AM, slavag wrote:

Thank You, I'll look on it,
Btw, is there any sample for text queries in Java API ?

Thank You.

On May 29, 8:58 am, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

Or, better yet in 0.16.1, text queries (though it has a bug in it for the Java API that will be fixed in 0.16.2).

On Sunday, May 29, 2011 at 1:18 AM, dpilato wrote:

Term request is case sensitive. querystring query should work.

Here is a good starting URL :
http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com (http://Nabble.com).


(Shay Banon) #11

Great :), there are some samples here: http://www.elasticsearch.org/guide/reference/java-api/query-dsl.html. And basically, all the queries that you can use exists in the QueryBuilders static factory, and all the filters are in FilterBuilders.

On Sunday, May 29, 2011 at 8:28 PM, slavag wrote:

Thank You.
As I said - started to use elasticsearch last night :slight_smile:

On May 29, 6:01 pm, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

replace QueryBuilders#term with QueryBuilders#text, pretty basic stuff.

On Sunday, May 29, 2011 at 11:02 AM, slavag wrote:

Thank You, I'll look on it,
Btw, is there any sample for text queries in Java API ?

Thank You.

On May 29, 8:58 am, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

Or, better yet in 0.16.1, text queries (though it has a bug in it for the Java API that will be fixed in 0.16.2).

On Sunday, May 29, 2011 at 1:18 AM, dpilato wrote:

Term request is case sensitive. querystring query should work.

Here is a good starting URL :
http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com (http://Nabble.com).


(Slava G ) #12

10x for advise.

On May 29, 8:39 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Great :), there are some samples here:http://www.elasticsearch.org/guide/reference/java-api/query-dsl.html. And basically, all the queries that you can use exists in the QueryBuilders static factory, and all the filters are in FilterBuilders.

On Sunday, May 29, 2011 at 8:28 PM, slavag wrote:

Thank You.
As I said - started to use elasticsearch last night :slight_smile:

On May 29, 6:01 pm, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

replace QueryBuilders#term with QueryBuilders#text, pretty basic stuff.

On Sunday, May 29, 2011 at 11:02 AM, slavag wrote:

Thank You, I'll look on it,
Btw, is there any sample for text queries in Java API ?

Thank You.

On May 29, 8:58 am, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

Or, better yet in 0.16.1, text queries (though it has a bug in it for the Java API that will be fixed in 0.16.2).

On Sunday, May 29, 2011 at 1:18 AM, dpilato wrote:

Term request is case sensitive. querystring query should work.

Here is a good starting URL :
http://www.elasticsearch.org/guide/reference/query-dsl/

Cheers
David

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp2997083p29...
Sent from the ElasticSearch Users mailing list archive at Nabble.com (http://Nabble.com).


(fashionalwallet) #13
  • deleted -

(system) #14