Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-2662 Elasticsearch: do not search on all indexes when searchi…
…ng on a dynamically sharded index with no shard
- Loading branch information
Showing
3 changed files
with
194 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...csearch/src/main/java/org/hibernate/search/elasticsearch/impl/EmptyDocumentExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.impl; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.lucene.search.TopDocs; | ||
import org.hibernate.search.elasticsearch.logging.impl.Log; | ||
import org.hibernate.search.query.engine.spi.DocumentExtractor; | ||
import org.hibernate.search.query.engine.spi.EntityInfo; | ||
import org.hibernate.search.util.logging.impl.LoggerFactory; | ||
|
||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
class EmptyDocumentExtractor implements DocumentExtractor { | ||
|
||
private static final Log log = LoggerFactory.make( Log.class ); | ||
|
||
private static final DocumentExtractor INSTANCE = new EmptyDocumentExtractor(); | ||
|
||
public static DocumentExtractor get() { | ||
return INSTANCE; | ||
} | ||
|
||
private EmptyDocumentExtractor() { | ||
// Use get() | ||
} | ||
|
||
@Override | ||
public EntityInfo extract(int index) throws IOException { | ||
throw new IndexOutOfBoundsException( "This document extractor is empty" ); | ||
} | ||
|
||
@Override | ||
public int getFirstIndex() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getMaxIndex() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// Nothing to do | ||
} | ||
|
||
@Override | ||
public TopDocs getTopDocs() { | ||
throw log.documentExtractorTopDocsUnsupported(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
elasticsearch/src/main/java/org/hibernate/search/elasticsearch/impl/EmptySearchResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.impl; | ||
|
||
import org.hibernate.search.elasticsearch.work.impl.SearchResult; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class EmptySearchResult implements SearchResult { | ||
|
||
private static final EmptySearchResult INSTANCE = new EmptySearchResult(); | ||
|
||
public static SearchResult get() { | ||
return INSTANCE; | ||
} | ||
|
||
private EmptySearchResult() { | ||
// Use get() | ||
} | ||
|
||
@Override | ||
public JsonArray getHits() { | ||
return new JsonArray(); | ||
} | ||
|
||
@Override | ||
public int getTotalHitCount() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public JsonObject getAggregations() { | ||
return new JsonObject(); | ||
} | ||
|
||
@Override | ||
public int getTook() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean getTimedOut() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getScrollId() { | ||
return null; | ||
} | ||
|
||
} |