本文整理汇总了Java中org.elasticsearch.search.rescore.RescoreBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RescoreBuilder类的具体用法?Java RescoreBuilder怎么用?Java RescoreBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RescoreBuilder类属于org.elasticsearch.search.rescore包,在下文中一共展示了RescoreBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testFromSize
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
public void testFromSize() throws Exception {
Builder settings = Settings.builder();
settings.put(SETTING_NUMBER_OF_SHARDS, 1);
settings.put(SETTING_NUMBER_OF_REPLICAS, 0);
assertAcked(prepareCreate("test").setSettings(settings));
for(int i=0;i<5;i++) {
client().prepareIndex("test", "type", ""+i).setSource("text", "hello world").get();
}
refresh();
SearchRequestBuilder request = client().prepareSearch();
request.setQuery(QueryBuilders.termQuery("text", "hello"));
request.setFrom(1);
request.setSize(4);
request.addRescorer(RescoreBuilder.queryRescorer(QueryBuilders.matchAllQuery()), 50);
assertEquals(4, request.get().getHits().getHits().length);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:QueryRescorerIT.java
示例2: build
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
@Override
public final SearchRequestBuilder build(Client client) {
checkNotNull(client, "client is required");
checkState(pageSize != null, "pageSize must be set");
Optional<QueryBuilder> query = this.query();
SearchRequestBuilder builder = client.prepareSearch(this.getIndex())
.setQuery(QueryBuilders.filteredQuery(query.orElse(QueryBuilders.matchAllQuery()), this.buildFilter()))
.setTypes(this.getDocumentType())
.setSize(this.getPageSize());
Optional<RescoreBuilder.Rescorer> rescoreBuilder = queryRescorer();
if (rescoreBuilder.isPresent()) {
builder.addRescorer(rescoreBuilder.get(), queryRescoreWindow());
}
if (this.from().isPresent()) {
builder.setFrom(this.from().get());
}
return builder;
}
开发者ID:bpatters,项目名称:eservice,代码行数:25,代码来源:AbstractElasticQueryBuilder.java
示例3: ShellScope
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Creates a new <code>ShellScope</code> given the actual scope object
* @param scope the actual scope object that depends on the engine in use
*/
ShellScope(Scope scope, ResourceRegistry resourceRegistry) {
this.scope = scope;
this.resourceRegistry = resourceRegistry;
registerJavaClass(Requests.class);
registerJavaClass(SearchSourceBuilder.class);
registerJavaClass(QueryBuilders.class);
registerJavaClass(FilterBuilders.class);
registerJavaClass(SortBuilders.class);
registerJavaClass(FacetBuilders.class);
registerJavaClass(RescoreBuilder.class);
registerJavaClass(SuggestBuilder.class);
registerJavaClass(AliasAction.class);
registerJavaClass(HttpParameters.class);
registerJavaClass(AllocateAllocationCommand.class);
registerJavaClass(CancelAllocationCommand.class);
registerJavaClass(MoveAllocationCommand.class);
registerJavaClass(ShardId.class);
}
开发者ID:javanna,项目名称:elasticshell,代码行数:23,代码来源:ShellScope.java
示例4: addRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
public SearchSourceBuilder addRescorer(RescoreBuilder<?> rescoreBuilder) {
if (rescoreBuilders == null) {
rescoreBuilders = new ArrayList<>();
}
rescoreBuilders.add(rescoreBuilder);
return this;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:SearchSourceBuilder.java
示例5: testMultipleRescores
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
public void testMultipleRescores() throws Exception {
int numDocs = indexRandomNumbers("keyword", 1, true);
QueryRescorerBuilder eightIsGreat = RescoreBuilder
.queryRescorer(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", English.intToEnglish(8)),
ScoreFunctionBuilders.weightFactorFunction(1000.0f)).boostMode(CombineFunction.REPLACE))
.setScoreMode(QueryRescoreMode.Total);
QueryRescorerBuilder sevenIsBetter = RescoreBuilder
.queryRescorer(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", English.intToEnglish(7)),
ScoreFunctionBuilders.weightFactorFunction(10000.0f)).boostMode(CombineFunction.REPLACE))
.setScoreMode(QueryRescoreMode.Total);
// First set the rescore window large enough that both rescores take effect
SearchRequestBuilder request = client().prepareSearch();
request.addRescorer(eightIsGreat, numDocs).addRescorer(sevenIsBetter, numDocs);
SearchResponse response = request.get();
assertFirstHit(response, hasId("7"));
assertSecondHit(response, hasId("8"));
// Now squash the second rescore window so it never gets to see a seven
response = request.setSize(1).clearRescorers().addRescorer(eightIsGreat, numDocs).addRescorer(sevenIsBetter, 1).get();
assertFirstHit(response, hasId("8"));
// We have no idea what the second hit will be because we didn't get a chance to look for seven
// Now use one rescore to drag the number we're looking for into the window of another
QueryRescorerBuilder ninetyIsGood = RescoreBuilder.queryRescorer(QueryBuilders
.functionScoreQuery(QueryBuilders.queryStringQuery("*ninety*"), ScoreFunctionBuilders.weightFactorFunction(1000.0f))
.boostMode(CombineFunction.REPLACE)).setScoreMode(QueryRescoreMode.Total);
QueryRescorerBuilder oneToo = RescoreBuilder.queryRescorer(QueryBuilders
.functionScoreQuery(QueryBuilders.queryStringQuery("*one*"), ScoreFunctionBuilders.weightFactorFunction(1000.0f))
.boostMode(CombineFunction.REPLACE)).setScoreMode(QueryRescoreMode.Total);
request.clearRescorers().addRescorer(ninetyIsGood, numDocs).addRescorer(oneToo, 10);
response = request.setSize(2).get();
assertThat(response.getHits().getMaxScore(), equalTo(response.getHits().getHits()[0].getScore()));
assertFirstHit(response, hasId("91"));
assertFirstHit(response, hasScore(2001.0f));
assertSecondHit(response, hasScore(1001.0f)); // Not sure which one it is but it is ninety something
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:QueryRescorerIT.java
示例6: addRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
public SearchSourceBuilder addRescorer(RescoreBuilder rescoreBuilder) {
if (rescoreBuilders == null) {
rescoreBuilders = new ArrayList<>();
}
rescoreBuilders.add(rescoreBuilder);
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:SearchSourceBuilder.java
示例7: registerRescorers
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
private void registerRescorers() {
namedWriteables.add(new NamedWriteableRegistry.Entry(RescoreBuilder.class, QueryRescorerBuilder.NAME, QueryRescorerBuilder::new));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:SearchModule.java
示例8: rescores
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Gets the bytes representing the rescore builders for this request.
*/
public List<RescoreBuilder> rescores() {
return rescoreBuilders;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:SearchSourceBuilder.java
示例9: testFullUsecase
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
public void testFullUsecase() throws Exception {
addElement(new StoredFeature("feature1", Collections.singletonList("query"), "mustache",
QueryBuilders.matchQuery("field1", "{{query}}").toString()));
addElement(new StoredFeature("feature2", Collections.singletonList("query"), "mustache",
QueryBuilders.matchQuery("field2", "{{query}}").toString()));
addElement(new StoredFeature("feature3", Collections.singletonList("query"), "derived_expression",
"(feature1 - feature2) > 0 ? 1 : -1"));
AddFeaturesToSetRequestBuilder builder = AddFeaturesToSetAction.INSTANCE.newRequestBuilder(client());
builder.request().setFeatureSet("my_set");
builder.request().setFeatureNameQuery("feature1");
builder.request().setStore(IndexFeatureStore.DEFAULT_STORE);
builder.execute().get();
builder.request().setFeatureNameQuery("feature2");
builder.execute().get();
builder.request().setFeatureNameQuery("feature3");
long version = builder.get().getResponse().getVersion();
CreateModelFromSetRequestBuilder createModelFromSetRequestBuilder = CreateModelFromSetAction.INSTANCE.newRequestBuilder(client());
createModelFromSetRequestBuilder.withVersion(IndexFeatureStore.DEFAULT_STORE, "my_set", version,
"my_model", new StoredLtrModel.LtrModelDefinition("model/linear", SIMPLE_MODEL, true));
createModelFromSetRequestBuilder.get();
buildIndex();
Map<String, Object> params = new HashMap<>();
boolean negativeScore = random().nextBoolean();
params.put("query", negativeScore ? "bonjour" : "hello");
SearchRequestBuilder sb = client().prepareSearch("test_index")
.setQuery(QueryBuilders.matchQuery("field1", "world"))
.setRescorer(RescoreBuilder
.queryRescorer(new WrapperQueryBuilder(new StoredLtrQueryBuilder(LtrTestUtils.nullLoader())
.modelName("my_model").params(params).toString()))
.setScoreMode(QueryRescoreMode.Total)
.setQueryWeight(0)
.setRescoreQueryWeight(1));
SearchResponse sr = sb.get();
assertEquals(1, sr.getHits().getTotalHits());
if(negativeScore) {
assertThat(sr.getHits().getAt(0).getScore(), Matchers.lessThan(-10.0f));
} else {
assertThat(sr.getHits().getAt(0).getScore(), Matchers.greaterThan(10.0f));
}
StoredLtrModel model = getElement(StoredLtrModel.class, StoredLtrModel.TYPE, "my_model");
CachesStatsNodesResponse stats = CachesStatsAction.INSTANCE.newRequestBuilder(client()).execute().get();
assertEquals(1, stats.getAll().getTotal().getCount());
assertEquals(model.compile(parserFactory()).ramBytesUsed(), stats.getAll().getTotal().getRam());
assertEquals(1, stats.getAll().getModels().getCount());
assertEquals(model.compile(parserFactory()).ramBytesUsed(), stats.getAll().getModels().getRam());
assertEquals(0, stats.getAll().getFeatures().getCount());
assertEquals(0, stats.getAll().getFeatures().getRam());
assertEquals(0, stats.getAll().getFeaturesets().getCount());
assertEquals(0, stats.getAll().getFeaturesets().getRam());
ClearCachesAction.RequestBuilder clearCache = ClearCachesAction.INSTANCE.newRequestBuilder(client());
clearCache.request().clearModel(IndexFeatureStore.DEFAULT_STORE, "my_model");
clearCache.get();
stats = CachesStatsAction.INSTANCE.newRequestBuilder(client()).execute().get();
assertEquals(0, stats.getAll().getTotal().getCount());
assertEquals(0, stats.getAll().getTotal().getRam());
}
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:66,代码来源:StoredLtrQueryIT.java
示例10: queryRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
@Override
protected Optional<RescoreBuilder.Rescorer> queryRescorer() {
return Optional.empty();
}
开发者ID:bpatters,项目名称:eservice,代码行数:5,代码来源:UserElasticQueryBuilder.java
示例11: searchProducts
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
@Override
public ProductSearchResult searchProducts(SearchCriteria searchCriteria)
{
QueryBuilder queryBuilder = getQueryBuilder(searchCriteria);
SearchRequestBuilder requestBuilder = getSearchRequestBuilder(searchCriteria.getIndexes(),
searchCriteria.getDocumentTypes(),
searchCriteria.getFrom(),
searchCriteria.getSize());
requestBuilder.addFields(SearchDocumentFieldName.productQueryFields);
if(searchCriteria.isRescoreOnSoldOut())
{
Rescorer rescorer = RescoreBuilder.queryRescorer(QueryBuilders.termQuery(SearchDocumentFieldName.SOLD_OUT.getFieldName(), false))
.setQueryWeight(1.0f) //default
.setRescoreQueryWeight(1.5f)
;
requestBuilder.setRescorer(rescorer);
}
if (searchCriteria.hasFilters())
{
AndFilterBuilder andFilterBuilder = getFilterBuilderForSearchCriteria(searchCriteria);
requestBuilder.setQuery(QueryBuilders.filteredQuery(queryBuilder, andFilterBuilder));
} else
{
requestBuilder.setQuery(queryBuilder);
}
if (!searchCriteria.isNoFacets() && searchCriteria.getFacets().size() > 0)
{
addFacets(searchCriteria, requestBuilder);
}
//Add sorting
if(searchCriteria.getSortOrder() !=null)
{
//First on given field
requestBuilder.addSort(SortBuilders.fieldSort(SearchDocumentFieldName.AVAILABLE_DATE.getFieldName()).order(searchCriteria.getSortOrder()).missing("_last"));
//then on score based
requestBuilder.addSort(SortBuilders.scoreSort());
}
logger.debug("Executing following search request:" + requestBuilder.internalBuilder().toString());
SearchResponse searchResponse = requestBuilder.execute().actionGet();
printSearchResponseForDebug(searchResponse);
return getProductSearchResults(searchResponse);
}
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:52,代码来源:ProductQueryServiceImpl.java
示例12: searchProducts
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
@Override
public ProductSearchResult searchProducts(final SearchCriteria searchCriteria)
{
final QueryBuilder queryBuilder = getQueryBuilder(searchCriteria);
final SearchRequestBuilder requestBuilder = getSearchRequestBuilder(searchCriteria.getIndexes(), searchCriteria.getDocumentTypes(),
searchCriteria.getFrom(), searchCriteria.getSize());
requestBuilder.addFields(SearchDocumentFieldName.productQueryFields);
if (searchCriteria.isRescoreOnSoldOut())
{
final Rescorer rescorer = RescoreBuilder
.queryRescorer(QueryBuilders.termQuery(SearchDocumentFieldName.SOLD_OUT.getFieldName(), false)).setQueryWeight(1.0f) // default
.setRescoreQueryWeight(1.5f);
requestBuilder.setRescorer(rescorer);
}
if (searchCriteria.hasFilters())
{
final AndFilterBuilder andFilterBuilder = getFilterBuilderForSearchCriteria(searchCriteria);
requestBuilder.setQuery(QueryBuilders.filteredQuery(queryBuilder, andFilterBuilder));
}
else
{
requestBuilder.setQuery(queryBuilder);
}
if (!searchCriteria.isNoFacets() && searchCriteria.getFacets().size() > 0)
{
addFacets(searchCriteria, requestBuilder);
}
// Add sorting
if (searchCriteria.getSortOrder() != null)
{
// First on given field
requestBuilder.addSort(SortBuilders.fieldSort(SearchDocumentFieldName.AVAILABLE_DATE.getFieldName())
.order(searchCriteria.getSortOrder()).missing("_last"));
// then on score based
requestBuilder.addSort(SortBuilders.scoreSort());
}
logger.debug("Executing following search request:" + requestBuilder.internalBuilder().toString());
final SearchResponse searchResponse = requestBuilder.execute().actionGet();
printSearchResponseForDebug(searchResponse);
return getProductSearchResults(searchResponse);
}
开发者ID:jaibeermalik,项目名称:elasticsearch-akka,代码行数:42,代码来源:ProductQueryServiceImpl.java
示例13: rescoreBuilder
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
private RescoreBuilder rescoreBuilder() {
return sourceBuilder().rescore();
}
开发者ID:javanna,项目名称:elasticshell,代码行数:4,代码来源:SearchRequestBuilder.java
示例14: searchProducts
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
@Override
public ProductSearchResult searchProducts(
final SearchCriteria searchCriteria) {
final QueryBuilder queryBuilder = getQueryBuilder(searchCriteria);
final SearchRequestBuilder requestBuilder = getSearchRequestBuilder(
searchCriteria.getIndexes(), searchCriteria.getDocumentTypes(),
searchCriteria.getFrom(), searchCriteria.getSize());
requestBuilder.addFields(SearchDocumentFieldName.productQueryFields);
if (searchCriteria.isRescoreOnSoldOut()) {
final Rescorer rescorer = RescoreBuilder
.queryRescorer(
QueryBuilders.termQuery(
SearchDocumentFieldName.SOLD_OUT
.getFieldName(), false))
.setQueryWeight(1.0f) // default
.setRescoreQueryWeight(1.5f);
requestBuilder.setRescorer(rescorer);
}
if (searchCriteria.hasFilters()) {
final AndFilterBuilder andFilterBuilder = getFilterBuilderForSearchCriteria(searchCriteria);
requestBuilder.setQuery(QueryBuilders.filteredQuery(queryBuilder,
andFilterBuilder));
} else {
requestBuilder.setQuery(queryBuilder);
}
if (!searchCriteria.isNoFacets()
&& searchCriteria.getFacets().size() > 0) {
addFacets(searchCriteria, requestBuilder);
}
// Add sorting
if (searchCriteria.getSortOrder() != null) {
// First on given field
requestBuilder.addSort(SortBuilders
.fieldSort(
SearchDocumentFieldName.AVAILABLE_DATE
.getFieldName())
.order(searchCriteria.getSortOrder()).missing("_last"));
// then on score based
requestBuilder.addSort(SortBuilders.scoreSort());
}
logger.debug("Executing following search request:"
+ requestBuilder.internalBuilder().toString());
final SearchResponse searchResponse = requestBuilder.execute()
.actionGet();
printSearchResponseForDebug(searchResponse);
return getProductSearchResults(searchResponse);
}
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:48,代码来源:ProductQueryServiceImpl.java
示例15: setRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Clears all rescorers on the builder and sets the first one. To use multiple rescore windows use
* {@link #addRescorer(org.elasticsearch.search.rescore.RescoreBuilder, int)}.
*
* @param rescorer rescorer configuration
* @return this for chaining
*/
public NoopSearchRequestBuilder setRescorer(RescoreBuilder<?> rescorer) {
sourceBuilder().clearRescorers();
return addRescorer(rescorer);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:NoopSearchRequestBuilder.java
示例16: addRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Adds a new rescorer.
*
* @param rescorer rescorer configuration
* @return this for chaining
*/
public NoopSearchRequestBuilder addRescorer(RescoreBuilder<?> rescorer) {
sourceBuilder().addRescorer(rescorer);
return this;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:NoopSearchRequestBuilder.java
示例17: setRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Clears all rescorers on the builder and sets the first one. To use multiple rescore windows use
* {@link #addRescorer(org.elasticsearch.search.rescore.RescoreBuilder, int)}.
*
* @param rescorer rescorer configuration
* @return this for chaining
*/
public SearchRequestBuilder setRescorer(RescoreBuilder<?> rescorer) {
sourceBuilder().clearRescorers();
return addRescorer(rescorer);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:SearchRequestBuilder.java
示例18: addRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Adds a new rescorer.
*
* @param rescorer rescorer configuration
* @return this for chaining
*/
public SearchRequestBuilder addRescorer(RescoreBuilder<?> rescorer) {
sourceBuilder().addRescorer(rescorer);
return this;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:SearchRequestBuilder.java
示例19: setRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Clears all rescorers on the builder and sets the first one. To use multiple rescore windows use
* {@link #addRescorer(org.elasticsearch.search.rescore.RescoreBuilder.Rescorer, int)}.
*
* @param rescorer rescorer configuration
* @return this for chaining
*/
public SearchRequestBuilder setRescorer(RescoreBuilder.Rescorer rescorer) {
sourceBuilder().clearRescorers();
return addRescorer(rescorer);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:SearchRequestBuilder.java
示例20: addRescorer
import org.elasticsearch.search.rescore.RescoreBuilder; //导入依赖的package包/类
/**
* Adds a new rescorer.
*
* @param rescorer rescorer configuration
* @return this for chaining
*/
public SearchRequestBuilder addRescorer(RescoreBuilder.Rescorer rescorer) {
sourceBuilder().addRescorer(new RescoreBuilder().rescorer(rescorer));
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:SearchRequestBuilder.java
注:本文中的org.elasticsearch.search.rescore.RescoreBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论