I asked question related to pagination in Elastic Search result fetched by titan here
Pagination with Elastic Search in Titan
and concluded that its not supporting right now so to get it I decided to search Titan
index directly using ES java client.
Here is ths Titan way of fetching ES records:
Iterable<Result<Vertex>> vertices = g.indexQuery("search","v.testTitle:(mytext)")
.addParameter(new Parameter("from", 0))
.addParameter(new Parameter("size", 2)).vertices();
for (Result<Vertex> result : vertices) {
Vertex tv = result.getElement();
System.out.println(tv.getProperty("testTitle")+ ": " + result.getScore());
}
Its return 1 record.
but addParameter() is not supported so pagination is not allowed. So i wanted to do same thing directly from ES java client as below:
Node node = nodeBuilder().node();
Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("127.0.0.1", 9300));
SearchResponse response = client.prepareSearch("titan")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.fieldQuery("testTitle", "mytext")) // Query
.execute()
.actionGet();
System.out.println(response.getHits().totalHits());
node.close();
Its printing zero in my case. but the same query in Titan code (above) return 1 record. Am I missing some Titan
specific parameters or options in this ES java code????
testTitle
notofferTitle
its my mistake. next thing is that I don't wanted more then pagination fromindexQuery
but as its not supported so I was thinking about searching ES index created by titan directly.My 1st code works fine if you dont consider pagination. I want to make second code equivalent to my 1st code but somewhere I am missing some parameter or options that its returning zero hit.I WANT TO RETURN SAME RESULT FROM USING SECOND CODE WITH ALL TITAN SPECIFIC ES SETTINGS. I hope you got my point – Manish Kumar