Strange search results with JAVA termQuery search

I have created an index at this location:
http://localhost:9200/ana.smth/Name/120918225128-a7217b24-db48

and it returns

{"_index":"ana.smth","_type":"Name","_id":"120918225128-a7217b24-db48","_version":2,"exists":true, "_source" :
{"feat":
{"elements":
{"lastName":"Smith","firstName":"Anna"},"featName":"Name"},
"obsEntId":"120918225128-5c79d1ed-1e38",
"_srch_index":"ana.smth",
"param1":"Anna",
"param2":"Smith",
"_srch_name":"Name",
"_srch_Id":"120918225128-a7217b24-db48","isValid":false
}
}

When i use the search java api like below :

       TermQueryBuilder tq = new TermQueryBuilder("_srch_index","ana.smth");
   //TermQueryBuilder tq = new TermQueryBuilder("param1","Anna");
	 
     SearchResponse response = client.prepareSearch(sq.getIndex())
            .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
	       
            .setQuery(tq)
       
	        .setFrom(0).setSize(60).setExplain(true)
	        .execute()
	        .actionGet();
    SearchHits sh = response.getHits();
    SearchHit[] shList = sh.getHits();

I can get a reponse (with hits) for TermQueryBuilder("_srch_index","ana.smth") but not TermQueryBuilder("param1","Anna") even though both
terms are inside the JSON result. Whats seems to be the problem ?

--

Try with anna to see if it works.

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

Le 18 sept. 2012 à 17:35, Percival Xavier xavier.percival@gmail.com a écrit :

I have created an index at this location:
http://localhost:9200/ana.smth/Name/120918225128-a7217b24-db48

and it returns
{"_index":"ana.smth","_type":"Name","_id":"120918225128-a7217b24-db48","_version":2,"exists":true, "_source" :
{"feat":
{"elements":
{"lastName":"Smith","firstName":"Anna"},"featName":"Name"},
"obsEntId":"120918225128-5c79d1ed-1e38",
"_srch_index":"ana.smth",
"param1":"Anna",
"param2":"Smith",
"_srch_name":"Name",
"_srch_Id":"120918225128-a7217b24-db48","isValid":false
}
}

When i use the search java api like below :

       TermQueryBuilder tq = new TermQueryBuilder("_srch_index","ana.smth");
 //TermQueryBuilder tq = new TermQueryBuilder("param1","Anna");
   
     SearchResponse response = client.prepareSearch(sq.getIndex())
            .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
         
            .setQuery(tq)
       
          .setFrom(0).setSize(60).setExplain(true)
          .execute()
          .actionGet();
    SearchHits sh = response.getHits();
    SearchHit[] shList = sh.getHits();

I can get a reponse (with hits) for TermQueryBuilder("_srch_index","ana.smth") but not TermQueryBuilder("param1","Anna") even though both
terms are inside the JSON result. Whats seems to be the problem ?

--

--

yes, it does! is there a reason why "anna" but not "Anna". both ways work
well for me but i'm just curious.

On Tuesday, September 18, 2012 11:38:48 PM UTC+8, David Pilato wrote:

Try with anna to see if it works.

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

Le 18 sept. 2012 à 17:35, Percival Xavier <xavier....@gmail.com<javascript:>>
a écrit :

I have created an index at this location:
http://localhost:9200/ana.smth/Name/120918225128-a7217b24-db48

and it returns

{"_index":"ana.smth","_type":"Name","_id":"120918225128-a7217b24-db48","_version":2,"exists":true, "_source" :
{"feat":
{"elements":
{"lastName":"Smith","firstName":"Anna"},"featName":"Name"},
"obsEntId":"120918225128-5c79d1ed-1e38",
"_srch_index":"ana.smth",
"param1":"Anna",
"param2":"Smith",
"_srch_name":"Name",
"_srch_Id":"120918225128-a7217b24-db48","isValid":false
}
}

When i use the search java api like below :

       TermQueryBuilder tq = new TermQueryBuilder("_srch_index","ana.smth");
 //TermQueryBuilder tq = new TermQueryBuilder("param1","Anna");
   
     SearchResponse response = client.prepareSearch(sq.getIndex())
            .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
         
            .setQuery(tq)
       
          .setFrom(0).setSize(60).setExplain(true)
          .execute()
          .actionGet();
    SearchHits sh = response.getHits();
    SearchHit[] shList = sh.getHits();

I can get a reponse (with hits) for TermQueryBuilder("_srch_index","ana.smth") but not TermQueryBuilder("param1","Anna") even though both
terms are inside the JSON result. Whats seems to be the problem ?

--

--

Yes. There's a good reason. TermQuery does not analyze content.
But, you have indexed your field with a default analyzer and Anna is indexed in
Lucene as anna.

TermQuery compare Anna with anna which did not match.
You can use a matchQuery (starting 0.19.9 or a TextQuery for previous versions)
which will analyze your content and will compare anna with anna

HTH
David

Le 18 septembre 2012 à 17:54, Percival Xavier xavier.percival@gmail.com a
écrit :

yes, it does! is there a reason why "anna" but not "Anna". both ways work
well for me but i'm just curious.

On Tuesday, September 18, 2012 11:38:48 PM UTC+8, David Pilato wrote:

Try with anna to see if it works.

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

Le 18 sept. 2012 à 17:35, Percival Xavier < xavier....@gmail.com> a écrit
:

   > > > 
   I have created an index at this location:
   http://localhost:9200/ana.smth/Name/120918225128-a7217b24-db48

   and it returns
    <http://localhost:9200/ana.smth/Name/120918225128-a7217b24-db48>


  {"_index":"ana.smth","_type":"Name","_id":"120918225128-a7217b24-db48","_version":2,"exists":true,

"_source" :
{"feat":
{"elements":

                       {"lastName":"Smith","firstName":"Anna"},"featName":"Name"},
                    "obsEntId":"120918225128-5c79d1ed-1e38",
                    "_srch_index":"ana.smth",
                    "param1":"Anna",
                    "param2":"Smith",
                    "_srch_name":"Name",

                   "_srch_Id":"120918225128-a7217b24-db48","isValid":false
                    }
              }

   When i use the search java api like below :

              TermQueryBuilder tq = new

TermQueryBuilder("_srch_index","ana.smth");
//TermQueryBuilder tq = new TermQueryBuilder("param1","Anna");

            SearchResponse response =

client.prepareSearch(sq.getIndex())
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)

                   .setQuery(tq)

             .setFrom(0).setSize(60).setExplain(true)
             .execute()
             .actionGet();
           SearchHits sh = response.getHits();
           SearchHit[] shList = sh.getHits();

   I can get a reponse (with hits) for

TermQueryBuilder("_srch_index","ana.smth") but not
TermQueryBuilder("param1","Anna") even though both
terms are inside the JSON result. Whats seems to be the problem ?

   --








   --

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--