org.elasticsearch.common.lucene.search.function.CombineFunction Java Examples
The following examples show how to use
org.elasticsearch.common.lucene.search.function.CombineFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DecayFunctionParser.java From Elasticsearch with Apache License 2.0 | 6 votes |
public AbstractDistanceScoreFunction(double userSuppiedScale, double decay, double offset, DecayFunction func, MultiValueMode mode) { super(CombineFunction.MULT); this.mode = mode; if (userSuppiedScale <= 0.0) { throw new IllegalArgumentException(FunctionScoreQueryParser.NAME + " : scale must be > 0.0."); } if (decay <= 0.0 || decay >= 1.0) { throw new IllegalArgumentException(FunctionScoreQueryParser.NAME + " : decay must be in the range [0..1]."); } this.scale = func.processScale(userSuppiedScale, decay); this.func = func; if (offset < 0.0d) { throw new IllegalArgumentException(FunctionScoreQueryParser.NAME + " : offset must be > 0.0"); } this.offset = offset; }
Example #2
Source File: FunctionScoreQueryParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
private CombineFunction parseBoostMode(QueryParseContext parseContext, XContentParser parser) throws IOException { String boostMode = parser.text(); CombineFunction cf = combineFunctionsMap.get(boostMode); if (cf == null) { throw new QueryParsingException(parseContext, "failed to parse [{}] query. illegal boost_mode [{}]", NAME, boostMode); } return cf; }
Example #3
Source File: FunctionsDemo.java From elasticsearch-full with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { FunctionScoreQueryBuilder.FilterFunctionBuilder [] filterFunctionBuilders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[] { new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.scriptFunction("doc['pubTime'].value*0.00000000001")), new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.scriptFunction("doc['opinionValue'].value*0.1")), }; QueryBuilders.functionScoreQuery( QueryBuilders.queryStringQuery("北京").defaultField("FIELD").field("titleZh^3.0"), filterFunctionBuilders ).boostMode(CombineFunction.MULTIPLY).scoreMode(FunctionScoreQuery.ScoreMode.AVG); }
Example #4
Source File: LoggingFetchSubPhaseTests.java From elasticsearch-learning-to-rank with Apache License 2.0 | 5 votes |
public Query buildFunctionScore() { FieldValueFactorFunction fieldValueFactorFunction = new FieldValueFactorFunction("score", FACTOR, LN2P, 0D, new SortedNumericDVIndexFieldData(new Index("test", "123"), "score", FLOAT)); return new FunctionScoreQuery(new MatchAllDocsQuery(), fieldValueFactorFunction, CombineFunction.MULTIPLY, 0F, Float.MAX_VALUE); }
Example #5
Source File: SuggestHelper.java From fess with Apache License 2.0 | 5 votes |
public void indexFromDocuments(final Consumer<Boolean> success, final Consumer<Throwable> error) { final FessConfig fessConfig = ComponentUtil.getFessConfig(); final long interval = fessConfig.getSuggestUpdateRequestIntervalAsInteger().longValue(); final int docPerReq = fessConfig.getSuggestUpdateDocPerRequestAsInteger(); final SystemHelper systemHelper = ComponentUtil.getSystemHelper(); suggester .indexer() .indexFromDocument( () -> { final ESSourceReader reader = new ESSourceReader(ComponentUtil.getFessEsClient(), suggester.settings(), fessConfig.getIndexDocumentSearchIndex(), "_doc"); // TODO remove type reader.setScrollSize(fessConfig.getSuggestSourceReaderScrollSizeAsInteger()); reader.setLimitDocNumPercentage(fessConfig.getSuggestUpdateContentsLimitNumPercentage()); reader.setLimitNumber(fessConfig.getSuggestUpdateContentsLimitNumAsInteger()); reader.setLimitOfDocumentSize(fessConfig.getSuggestUpdateContentsLimitDocSizeAsInteger()); final List<FunctionScoreQueryBuilder.FilterFunctionBuilder> flist = new ArrayList<>(); flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.randomFunction() .seed(System.currentTimeMillis()).setField(fessConfig.getIndexFieldDocId()))); reader.setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.matchAllQuery(), flist.toArray(new FunctionScoreQueryBuilder.FilterFunctionBuilder[flist.size()])).boostMode( CombineFunction.MULTIPLY)); reader.addSort(SortBuilders.fieldSort(fessConfig.getIndexFieldClickCount())); reader.addSort(SortBuilders.scoreSort()); return reader; }, docPerReq, () -> { systemHelper.calibrateCpuLoad(); ThreadUtil.sleep(interval); }).then(response -> { refresh(); success.accept(true); }).error(t -> error.accept(t)); }
Example #6
Source File: FunctionScoreQueryBuilder.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Score mode defines how the combined result of score functions will influence the final score together with the sub query score. */ public FunctionScoreQueryBuilder boostMode(CombineFunction combineFunction) { this.boostMode = combineFunction.getName(); return this; }