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 ?
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 ?
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
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");
.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 ?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.