Java API

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.

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

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.

What about test in lowercase ?

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.

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

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 :
Elasticsearch Platform — Find real-time answers at scale | Elastic

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).

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 :
Elasticsearch Platform — Find real-time answers at scale | Elastic

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).

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 :
Elasticsearch Platform — Find real-time answers at scale | Elastic

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).

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 :
Elasticsearch Platform — Find real-time answers at scale | Elastic

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).

Great :), there are some samples here: Elasticsearch Platform — Find real-time answers at scale | Elastic. 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 :
Elasticsearch Platform — Find real-time answers at scale | Elastic

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).

10x for advise.

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

Great :), there are some samples here:Elasticsearch Platform — Find real-time answers at scale | Elastic. 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 :
Elasticsearch Platform — Find real-time answers at scale | Elastic

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).

  • deleted -