0
votes

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????

1
Manish, I follow your duplicated questions on our mailing list and here on SO and I'm a bit tired of answering those questions. Please learn a bit more about the basics how Titan is working, before you start bothering the ES people. There's no field named "offerTitle" in your ES index, Titan encodes all property names for several reasons. You're diving way too deep with too few knowledge.Daniel Kuppitz
First i am sorry its testTitle not offerTitle its my mistake. next thing is that I don't wanted more then pagination from indexQuery 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 pointManish Kumar
I got your point long time ago and your question was already fully answered.Daniel Kuppitz

1 Answers

0
votes

I think that Titan is sending a QueryStringQuery. That said, I would recommend using a MatchQuery.

QueryBuilders.matchQuery("offerTitle", "your text whatever you want")