Search in sources :

Example 1 with SearchRowLocations

use of com.couchbase.client.java.search.result.SearchRowLocations in project couchbase-jvm-clients by couchbase.

the class SearchIntegrationTest method searchIncludeLocations.

@Test
void searchIncludeLocations() throws Throwable {
    String docId = UUID.randomUUID().toString();
    MutationResult insertResult = collection.insert(docId, mapOf("name", "billy"));
    try {
        runWithRetry(Duration.ofSeconds(30), () -> {
            SearchResult result = cluster.searchQuery(indexName, queryString("billy"), searchOptions().consistentWith(MutationState.from(insertResult.mutationToken().get())).includeLocations(true));
            List<SearchRowLocations> locationsList = result.rows().stream().map(SearchRow::locations).filter(opt -> opt.isPresent()).map(Optional::get).collect(toList());
            assertTrue(!locationsList.isEmpty());
        });
    } finally {
        collection.remove(docId);
    }
}
Also used : SearchRowLocations(com.couchbase.client.java.search.result.SearchRowLocations) SearchResult(com.couchbase.client.java.search.result.SearchResult) SearchQuery.queryString(com.couchbase.client.java.search.SearchQuery.queryString) MutationResult(com.couchbase.client.java.kv.MutationResult) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

MutationResult (com.couchbase.client.java.kv.MutationResult)1 SearchQuery.queryString (com.couchbase.client.java.search.SearchQuery.queryString)1 SearchResult (com.couchbase.client.java.search.result.SearchResult)1 SearchRowLocations (com.couchbase.client.java.search.result.SearchRowLocations)1 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)1 Test (org.junit.jupiter.api.Test)1