Search in sources :

Example 1 with LuceneQuery

use of org.apache.geode.cache.lucene.LuceneQuery in project geode by apache.

the class LuceneManagementDUnitTest method queryEntries.

private void queryEntries(String regionName, String indexName) throws LuceneQueryException {
    LuceneService service = LuceneServiceProvider.get(getCache());
    LuceneQuery query = service.createLuceneQueryFactory().create(indexName, regionName, "field0:0", null);
    query.findValues();
}
Also used : LuceneQuery(org.apache.geode.cache.lucene.LuceneQuery) LuceneService(org.apache.geode.cache.lucene.LuceneService)

Example 2 with LuceneQuery

use of org.apache.geode.cache.lucene.LuceneQuery in project geode by apache.

the class LuceneSearchIndexFunctionJUnitTest method getMockLuceneService.

private InternalLuceneService getMockLuceneService(String resultKey, String resultValue, String resultScore) throws LuceneQueryException {
    InternalLuceneService service = mock(InternalLuceneService.class);
    LuceneQueryFactory mockQueryFactory = spy(LuceneQueryFactory.class);
    LuceneQuery mockQuery = mock(LuceneQuery.class);
    PageableLuceneQueryResults pageableLuceneQueryResults = mock(PageableLuceneQueryResults.class);
    LuceneResultStruct<String, String> resultStruct = new LuceneResultStructImpl(resultKey, resultValue, Float.valueOf(resultScore));
    List<LuceneResultStruct<String, String>> queryResults = new ArrayList<>();
    queryResults.add(resultStruct);
    doReturn(mock(LuceneIndex.class)).when(service).getIndex(anyString(), anyString());
    doReturn(mockQueryFactory).when(service).createLuceneQueryFactory();
    doReturn(mockQueryFactory).when(mockQueryFactory).setLimit(anyInt());
    doReturn(mockQuery).when(mockQueryFactory).create(any(), any(), any(), any());
    when(mockQuery.findPages()).thenReturn(pageableLuceneQueryResults);
    when(pageableLuceneQueryResults.hasNext()).thenReturn(true).thenReturn(false);
    when(pageableLuceneQueryResults.next()).thenReturn(queryResults);
    return service;
}
Also used : LuceneQuery(org.apache.geode.cache.lucene.LuceneQuery) LuceneResultStructImpl(org.apache.geode.cache.lucene.internal.LuceneResultStructImpl) PageableLuceneQueryResults(org.apache.geode.cache.lucene.PageableLuceneQueryResults) LuceneIndex(org.apache.geode.cache.lucene.LuceneIndex) ArrayList(java.util.ArrayList) InternalLuceneService(org.apache.geode.cache.lucene.internal.InternalLuceneService) LuceneQueryFactory(org.apache.geode.cache.lucene.LuceneQueryFactory) LuceneResultStruct(org.apache.geode.cache.lucene.LuceneResultStruct)

Aggregations

LuceneQuery (org.apache.geode.cache.lucene.LuceneQuery)2 ArrayList (java.util.ArrayList)1 LuceneIndex (org.apache.geode.cache.lucene.LuceneIndex)1 LuceneQueryFactory (org.apache.geode.cache.lucene.LuceneQueryFactory)1 LuceneResultStruct (org.apache.geode.cache.lucene.LuceneResultStruct)1 LuceneService (org.apache.geode.cache.lucene.LuceneService)1 PageableLuceneQueryResults (org.apache.geode.cache.lucene.PageableLuceneQueryResults)1 InternalLuceneService (org.apache.geode.cache.lucene.internal.InternalLuceneService)1 LuceneResultStructImpl (org.apache.geode.cache.lucene.internal.LuceneResultStructImpl)1