Unable to obtain search results with java client

Hi everyone,

I'm just discovering elasticsearch this week and i would like to replace in
my company a DB2 search with elasticsearch capabilities.

I insert 1 million personn in a signe node.

When i user rest api (calling
http://localhost:9200/personne/_search?q=prenom:clarence&pretty=true URL) ,
i obtain the following results :

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1977,
"max_score" : 7.3687563,
"hits" : [ {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "GGBxRnJVS1mT6SvJxCGmmQ",
"_score" : 7.3687563, "_source" : {"nom":"Ford","prenom":"Clarence","codePostal":8323,"pays":"FRANCE","dateNaissance":"1960-02-01T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "7oemmrCnSqqNA7FbM7VM1Q",
"_score" : 7.3687563, "_source" : {"nom":"Allen","prenom":"Clarence","codePostal":49299,"pays":"FRANCE","dateNaissance":"1981-04-26T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "-So1k6tDT0Gnoy3mlG_KhA",
"_score" : 7.3687563, "_source" : {"nom":"Serrano","prenom":"Clarence","codePostal":57311,"pays":"FRANCE","dateNaissance":"1983-07-24T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "V_YfrN3tSUmTs0ryXtMFiw",
"_score" : 7.3687563, "_source" : {"nom":"McFarland","prenom":"Clarence","codePostal":67063,"pays":"FRANCE","dateNaissance":"1981-09-03T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "74_Q17zFRhWCaQR4xdrhtQ",
"_score" : 7.3687563, "_source" : {"nom":"Clark","prenom":"Clarence","codePostal":45505,"pays":"FRANCE","dateNaissance":"1966-04-16T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "CY8262_BR3SzA5Eptpk7GA",
"_score" : 7.3687563, "_source" : {"nom":"Simon","prenom":"Clarence","codePostal":79043,"pays":"FRANCE","dateNaissance":"1966-01-08T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "RdhvKLpYQWulUYoRWSxeuQ",
"_score" : 7.3687563, "_source" : {"nom":"Fuller","prenom":"Clarence","codePostal":74665,"pays":"FRANCE","dateNaissance":"1962-03-03T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "kvHP94hMQu-8Ur4sdkFSXQ",
"_score" : 7.3687563, "_source" : {"nom":"Dawson","prenom":"Clarence","codePostal":18510,"pays":"FRANCE","dateNaissance":"1964-05-23T00:00:00.000Z"}
}, {

...

When i do the same search with java client with the following code :

node = NodeBuilder.nodeBuilder().node();
Client client = node.client();

    SearchResponse response = client.prepareSearch("personne")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            .setQuery(termQuery("prenom", "Clarence"))
            .setFrom(0).setSize(10).setExplain(true)
            .setScroll(new TimeValue(600000))
            .execute()
            .actionGet();

    System.out.println(response.toString());

i got 0 result :

{
"_scroll_id" :
"cXVlcnlBbmRGZXRjaDs1OzYyNzpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYzMDpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyOTpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyODpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyNjpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzA7",
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

Did i miss something ?
Thanks for your answer

Try Clarence in lower case : clarence

HTH
David :wink:
@dadoonet

Le 17 mars 2012 à 09:26, damien Gouyette damien.gouyette@gmail.com a écrit :

Hi everyone,

I'm just discovering elasticsearch this week and i would like to replace in my company a DB2 search with elasticsearch capabilities.

I insert 1 million personn in a signe node.

When i user rest api (calling http://localhost:9200/personne/_search?q=prenom:clarence&pretty=true URL) , i obtain the following results :

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1977,
"max_score" : 7.3687563,
"hits" : [ {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "GGBxRnJVS1mT6SvJxCGmmQ",
"_score" : 7.3687563, "_source" : {"nom":"Ford","prenom":"Clarence","codePostal":8323,"pays":"FRANCE","dateNaissance":"1960-02-01T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "7oemmrCnSqqNA7FbM7VM1Q",
"_score" : 7.3687563, "_source" : {"nom":"Allen","prenom":"Clarence","codePostal":49299,"pays":"FRANCE","dateNaissance":"1981-04-26T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "-So1k6tDT0Gnoy3mlG_KhA",
"_score" : 7.3687563, "_source" : {"nom":"Serrano","prenom":"Clarence","codePostal":57311,"pays":"FRANCE","dateNaissance":"1983-07-24T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "V_YfrN3tSUmTs0ryXtMFiw",
"_score" : 7.3687563, "_source" : {"nom":"McFarland","prenom":"Clarence","codePostal":67063,"pays":"FRANCE","dateNaissance":"1981-09-03T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "74_Q17zFRhWCaQR4xdrhtQ",
"_score" : 7.3687563, "_source" : {"nom":"Clark","prenom":"Clarence","codePostal":45505,"pays":"FRANCE","dateNaissance":"1966-04-16T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "CY8262_BR3SzA5Eptpk7GA",
"_score" : 7.3687563, "_source" : {"nom":"Simon","prenom":"Clarence","codePostal":79043,"pays":"FRANCE","dateNaissance":"1966-01-08T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "RdhvKLpYQWulUYoRWSxeuQ",
"_score" : 7.3687563, "_source" : {"nom":"Fuller","prenom":"Clarence","codePostal":74665,"pays":"FRANCE","dateNaissance":"1962-03-03T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "kvHP94hMQu-8Ur4sdkFSXQ",
"_score" : 7.3687563, "_source" : {"nom":"Dawson","prenom":"Clarence","codePostal":18510,"pays":"FRANCE","dateNaissance":"1964-05-23T00:00:00.000Z"}
}, {
...

When i do the same search with java client with the following code :

node = NodeBuilder.nodeBuilder().node();
Client client = node.client();

    SearchResponse response = client.prepareSearch("personne")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            .setQuery(termQuery("prenom", "Clarence"))
            .setFrom(0).setSize(10).setExplain(true)
            .setScroll(new TimeValue(600000))
            .execute()
            .actionGet();

    System.out.println(response.toString());

i got 0 result :

{
"_scroll_id" : "cXVlcnlBbmRGZXRjaDs1OzYyNzpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYzMDpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyOTpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyODpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyNjpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzA7",
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

Did i miss something ?
Thanks for your answer

That's it.

I tried a lot pf other things, but not that.
Thanks for your answer.

Le samedi 17 mars 2012 09:28:43 UTC+1, David Pilato a écrit :

Try Clarence in lower case : clarence

HTH
David :wink:
@dadoonet

Hi everyone,

I'm just discovering elasticsearch this week and i would like to replace
in my company a DB2 search with elasticsearch capabilities.

I insert 1 million personn in a signe node.

When i user rest api (calling
http://localhost:9200/personne/_search?q=prenom:clarence&pretty=true URL)
, i obtain the following results :

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1977,
"max_score" : 7.3687563,
"hits" : [ {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "GGBxRnJVS1mT6SvJxCGmmQ",
"_score" : 7.3687563, "_source" :
{"nom":"Ford","prenom":"Clarence","codePostal":8323,"pays":"FRANCE","dateNaissance":"1960-02-01T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "7oemmrCnSqqNA7FbM7VM1Q",
"_score" : 7.3687563, "_source" :
{"nom":"Allen","prenom":"Clarence","codePostal":49299,"pays":"FRANCE","dateNaissance":"1981-04-26T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "-So1k6tDT0Gnoy3mlG_KhA",
"_score" : 7.3687563, "_source" :
{"nom":"Serrano","prenom":"Clarence","codePostal":57311,"pays":"FRANCE","dateNaissance":"1983-07-24T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "V_YfrN3tSUmTs0ryXtMFiw",
"_score" : 7.3687563, "_source" :
{"nom":"McFarland","prenom":"Clarence","codePostal":67063,"pays":"FRANCE","dateNaissance":"1981-09-03T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "74_Q17zFRhWCaQR4xdrhtQ",
"_score" : 7.3687563, "_source" :
{"nom":"Clark","prenom":"Clarence","codePostal":45505,"pays":"FRANCE","dateNaissance":"1966-04-16T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "CY8262_BR3SzA5Eptpk7GA",
"_score" : 7.3687563, "_source" :
{"nom":"Simon","prenom":"Clarence","codePostal":79043,"pays":"FRANCE","dateNaissance":"1966-01-08T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "RdhvKLpYQWulUYoRWSxeuQ",
"_score" : 7.3687563, "_source" :
{"nom":"Fuller","prenom":"Clarence","codePostal":74665,"pays":"FRANCE","dateNaissance":"1962-03-03T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "kvHP94hMQu-8Ur4sdkFSXQ",
"_score" : 7.3687563, "_source" :
{"nom":"Dawson","prenom":"Clarence","codePostal":18510,"pays":"FRANCE","dateNaissance":"1964-05-23T00:00:00.000Z"}
}, {
...

When i do the same search with java client with the following code :

node = NodeBuilder.nodeBuilder().node();
Client client = node.client();

    SearchResponse response = client.prepareSearch("personne")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            .setQuery(termQuery("prenom", "Clarence"))
            .setFrom(0).setSize(10).setExplain(true)
            .setScroll(new TimeValue(600000))
            .execute()
            .actionGet();

    System.out.println(response.toString());

i got 0 result :

{
"_scroll_id" :
"cXVlcnlBbmRGZXRjaDs1OzYyNzpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYzMDpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyOTpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyODpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyNjpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzA7",
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

Did i miss something ?
Thanks for your answer

Not the same comportement between rest api and java api

Clarence in rest = ok
clarence in rest = ok
ClArEnCe in rest = ok

clarence in java = ok
Clarence in java = ko
ClArEnCe in java = ko

is there a setting parameter to enable case sensitive ?
Default parameter should be the same between rest and java API

Regards

Damien

Le samedi 17 mars 2012 09:56:54 UTC+1, damien Gouyette a écrit :

That's it.

I tried a lot pf other things, but not that.
Thanks for your answer.

Le samedi 17 mars 2012 09:28:43 UTC+1, David Pilato a écrit :

Try Clarence in lower case : clarence

HTH
David :wink:
@dadoonet

Hi everyone,

I'm just discovering elasticsearch this week and i would like to
replace in my company a DB2 search with elasticsearch capabilities.

I insert 1 million personn in a signe node.

When i user rest api (calling
http://localhost:9200/personne/_search?q=prenom:clarence&pretty=trueURL) , i obtain the following results :

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1977,
"max_score" : 7.3687563,
"hits" : [ {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "GGBxRnJVS1mT6SvJxCGmmQ",
"_score" : 7.3687563, "_source" :
{"nom":"Ford","prenom":"Clarence","codePostal":8323,"pays":"FRANCE","dateNaissance":"1960-02-01T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "7oemmrCnSqqNA7FbM7VM1Q",
"_score" : 7.3687563, "_source" :
{"nom":"Allen","prenom":"Clarence","codePostal":49299,"pays":"FRANCE","dateNaissance":"1981-04-26T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "-So1k6tDT0Gnoy3mlG_KhA",
"_score" : 7.3687563, "_source" :
{"nom":"Serrano","prenom":"Clarence","codePostal":57311,"pays":"FRANCE","dateNaissance":"1983-07-24T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "V_YfrN3tSUmTs0ryXtMFiw",
"_score" : 7.3687563, "_source" :
{"nom":"McFarland","prenom":"Clarence","codePostal":67063,"pays":"FRANCE","dateNaissance":"1981-09-03T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "74_Q17zFRhWCaQR4xdrhtQ",
"_score" : 7.3687563, "_source" :
{"nom":"Clark","prenom":"Clarence","codePostal":45505,"pays":"FRANCE","dateNaissance":"1966-04-16T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "CY8262_BR3SzA5Eptpk7GA",
"_score" : 7.3687563, "_source" :
{"nom":"Simon","prenom":"Clarence","codePostal":79043,"pays":"FRANCE","dateNaissance":"1966-01-08T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "RdhvKLpYQWulUYoRWSxeuQ",
"_score" : 7.3687563, "_source" :
{"nom":"Fuller","prenom":"Clarence","codePostal":74665,"pays":"FRANCE","dateNaissance":"1962-03-03T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "kvHP94hMQu-8Ur4sdkFSXQ",
"_score" : 7.3687563, "_source" :
{"nom":"Dawson","prenom":"Clarence","codePostal":18510,"pays":"FRANCE","dateNaissance":"1964-05-23T00:00:00.000Z"}
}, {
...

When i do the same search with java client with the following code :

node = NodeBuilder.nodeBuilder().node();
Client client = node.client();

    SearchResponse response = client.prepareSearch("personne")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            .setQuery(termQuery("prenom", "Clarence"))
            .setFrom(0).setSize(10).setExplain(true)
            .setScroll(new TimeValue(600000))
            .execute()
            .actionGet();

    System.out.println(response.toString());

i got 0 result :

{
"_scroll_id" :
"cXVlcnlBbmRGZXRjaDs1OzYyNzpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYzMDpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyOTpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyODpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyNjpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzA7",
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

Did i miss something ?
Thanks for your answer

You are not doing exactly the same request.
In java you asked for a termQuery.
If think that ?q= is mapped to a textQuery Elasticsearch Platform — Find real-time answers at scale | Elastic
Or a querystring query : Elasticsearch Platform — Find real-time answers at scale | Elastic

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 17 mars 2012 à 10:04, damien Gouyette damien.gouyette@gmail.com a écrit :

Not the same comportement between rest api and java api

Clarence in rest = ok
clarence in rest = ok
ClArEnCe in rest = ok

clarence in java = ok
Clarence in java = ko
ClArEnCe in java = ko

is there a setting parameter to enable case sensitive ?
Default parameter should be the same between rest and java API

Regards

Damien

Le samedi 17 mars 2012 09:56:54 UTC+1, damien Gouyette a écrit :
That's it.

I tried a lot pf other things, but not that.
Thanks for your answer.

Le samedi 17 mars 2012 09:28:43 UTC+1, David Pilato a écrit :
Try Clarence in lower case : clarence
HTH
David :wink:
@dadoonet

Hi everyone,

I'm just discovering elasticsearch this week and i would like to replace in my company a DB2 search with elasticsearch capabilities.

I insert 1 million personn in a signe node.

When i user rest api (calling http://localhost:9200/personne/_search?q=prenom:clarence&pretty=true URL) , i obtain the following results :

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1977,
"max_score" : 7.3687563,
"hits" : [ {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "GGBxRnJVS1mT6SvJxCGmmQ",
"_score" : 7.3687563, "_source" : {"nom":"Ford","prenom":"Clarence","codePostal":8323,"pays":"FRANCE","dateNaissance":"1960-02-01T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "7oemmrCnSqqNA7FbM7VM1Q",
"_score" : 7.3687563, "_source" : {"nom":"Allen","prenom":"Clarence","codePostal":49299,"pays":"FRANCE","dateNaissance":"1981-04-26T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "-So1k6tDT0Gnoy3mlG_KhA",
"_score" : 7.3687563, "_source" : {"nom":"Serrano","prenom":"Clarence","codePostal":57311,"pays":"FRANCE","dateNaissance":"1983-07-24T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "V_YfrN3tSUmTs0ryXtMFiw",
"_score" : 7.3687563, "_source" : {"nom":"McFarland","prenom":"Clarence","codePostal":67063,"pays":"FRANCE","dateNaissance":"1981-09-03T23:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "74_Q17zFRhWCaQR4xdrhtQ",
"_score" : 7.3687563, "_source" : {"nom":"Clark","prenom":"Clarence","codePostal":45505,"pays":"FRANCE","dateNaissance":"1966-04-16T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "CY8262_BR3SzA5Eptpk7GA",
"_score" : 7.3687563, "_source" : {"nom":"Simon","prenom":"Clarence","codePostal":79043,"pays":"FRANCE","dateNaissance":"1966-01-08T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "RdhvKLpYQWulUYoRWSxeuQ",
"_score" : 7.3687563, "_source" : {"nom":"Fuller","prenom":"Clarence","codePostal":74665,"pays":"FRANCE","dateNaissance":"1962-03-03T00:00:00.000Z"}
}, {
"_index" : "personne",
"_type" : "personnephysique",
"_id" : "kvHP94hMQu-8Ur4sdkFSXQ",
"_score" : 7.3687563, "_source" : {"nom":"Dawson","prenom":"Clarence","codePostal":18510,"pays":"FRANCE","dateNaissance":"1964-05-23T00:00:00.000Z"}
}, {
...

When i do the same search with java client with the following code :

node = NodeBuilder.nodeBuilder().node();
Client client = node.client();

    SearchResponse response = client.prepareSearch("personne")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            .setQuery(termQuery("prenom", "Clarence"))
            .setFrom(0).setSize(10).setExplain(true)
            .setScroll(new TimeValue(600000))
            .execute()
            .actionGet();

    System.out.println(response.toString());

i got 0 result :

{
"_scroll_id" : "cXVlcnlBbmRGZXRjaDs1OzYyNzpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYzMDpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyOTpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyODpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzYyNjpXeG9pQWc3OFRPSzNVeldyUTJUa0lROzA7",
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

Did i miss something ?
Thanks for your answer

Thanks for preciseness. I used termquery because it's the default example.

Now let's go to benchmark

See you soon at devoxxfr :wink: