Search in sources :

Example 1 with OneSuggestLookupResponse

use of com.yelp.nrtsearch.server.grpc.OneSuggestLookupResponse in project nrtsearch by Yelp.

the class YelpSuggestTest method main.

// Run with args host && port && remote tmp dir in order
public static void main(String[] args) throws Exception {
    // The dir where the indices will live in the remote server
    Path yelp_suggest_test_base_path = Paths.get(System.getProperty("suggestTmp"));
    // The client who will be talking to the remote server
    LuceneServerClient standaloneServerClient = new LuceneServerClient(System.getProperty("suggestHost"), Integer.parseInt(System.getProperty("suggestPort")));
    setUpIndex(standaloneServerClient, INDEX_NAME, SUGGESTIONS_FILE_PATH, new YelpSuggestTest.OneDocBuilderImpl());
    // build Suggester
    buildSuggester(standaloneServerClient);
    // look up suggestions
    SuggestLookupRequest.Builder suggestLookupBuilder = SuggestLookupRequest.newBuilder();
    suggestLookupBuilder.setIndexName(INDEX_NAME);
    suggestLookupBuilder.setText("a");
    suggestLookupBuilder.setSuggestName("suggest_0");
    suggestLookupBuilder.setHighlight(true);
    // Set SF lat lon lookup
    List<String> sanFranGeohashes = getGeoHashes(37.785371, -122.459446, 5, 7);
    for (String geohash : sanFranGeohashes) {
        suggestLookupBuilder.addContexts(geohash);
    }
    SuggestLookupResponse suggestResponse = standaloneServerClient.getBlockingStub().suggestLookup(suggestLookupBuilder.build());
    List<OneSuggestLookupResponse> suggestResponseResultsList = suggestResponse.getResultsList();
    System.out.println(suggestResponseResultsList);
    System.exit(0);
}
Also used : Path(java.nio.file.Path) LuceneServerClient(com.yelp.nrtsearch.server.grpc.LuceneServerClient) SuggestLookupResponse(com.yelp.nrtsearch.server.grpc.SuggestLookupResponse) OneSuggestLookupResponse(com.yelp.nrtsearch.server.grpc.OneSuggestLookupResponse) OneSuggestLookupResponse(com.yelp.nrtsearch.server.grpc.OneSuggestLookupResponse) SuggestLookupRequest(com.yelp.nrtsearch.server.grpc.SuggestLookupRequest)

Aggregations

LuceneServerClient (com.yelp.nrtsearch.server.grpc.LuceneServerClient)1 OneSuggestLookupResponse (com.yelp.nrtsearch.server.grpc.OneSuggestLookupResponse)1 SuggestLookupRequest (com.yelp.nrtsearch.server.grpc.SuggestLookupRequest)1 SuggestLookupResponse (com.yelp.nrtsearch.server.grpc.SuggestLookupResponse)1 Path (java.nio.file.Path)1