Java Code Examples for org.apache.lucene.queries.BlendedTermQuery#dismaxBlendedQuery()
The following examples show how to use
org.apache.lucene.queries.BlendedTermQuery#dismaxBlendedQuery() .
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: MultiMatchQueryBuilder.java From Elasticsearch with Apache License 2.0 | 6 votes |
public Query blendTerm(Term term, MappedFieldType fieldType) { if (blendedFields == null) { return super.blendTerm(term, fieldType); } final Term[] terms = new Term[blendedFields.length]; float[] blendedBoost = new float[blendedFields.length]; for (int i = 0; i < blendedFields.length; i++) { terms[i] = blendedFields[i].newTerm(term.text()); blendedBoost[i] = blendedFields[i].boost; } if (options.commonTermsCutoff() != null) { return BlendedTermQuery.commonTermsBlendedQuery( terms, blendedBoost, false, options.commonTermsCutoff()); } if (tieBreaker == 1.0f) { return BlendedTermQuery.booleanBlendedQuery(terms, blendedBoost, false); } return BlendedTermQuery.dismaxBlendedQuery(terms, blendedBoost, tieBreaker); }
Example 2
Source File: MultiMatchQuery.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Query blendTerm(Term term, MappedFieldType fieldType) { if (blendedFields == null) { return super.blendTerm(term, fieldType); } final Term[] terms = new Term[blendedFields.length]; float[] blendedBoost = new float[blendedFields.length]; for (int i = 0; i < blendedFields.length; i++) { terms[i] = blendedFields[i].newTerm(term.text()); blendedBoost[i] = blendedFields[i].boost; } if (commonTermsCutoff != null) { return BlendedTermQuery.commonTermsBlendedQuery(terms, blendedBoost, false, commonTermsCutoff); } if (tieBreaker == 1.0f) { return BlendedTermQuery.booleanBlendedQuery(terms, blendedBoost, false); } return BlendedTermQuery.dismaxBlendedQuery(terms, blendedBoost, tieBreaker); }
Example 3
Source File: LtrQueryTests.java From elasticsearch-learning-to-rank with Apache License 2.0 | 5 votes |
public void testNoMatchQueries() throws IOException { String userQuery = "brown cow"; Term[] termsToBlend = new Term[]{new Term("field", userQuery.split(" ")[0])}; Query blended = BlendedTermQuery.dismaxBlendedQuery(termsToBlend, 1f); List<PrebuiltFeature> features = Arrays.asList( new PrebuiltFeature(null, new TermQuery(new Term("field", "missingterm"))), new PrebuiltFeature(null, blended)); checkModelWithFeatures(features, null, null); }
Example 4
Source File: LtrQueryTests.java From elasticsearch-learning-to-rank with Apache License 2.0 | 3 votes |
public void testOnRewrittenQueries() throws IOException { String userQuery = "brown cow"; Term[] termsToBlend = new Term[]{new Term("field", userQuery.split(" ")[0])}; Query blended = BlendedTermQuery.dismaxBlendedQuery(termsToBlend, 1f); List<Query> features = Arrays.asList(new TermQuery(new Term("field", userQuery.split(" ")[0])), blended); checkModelWithFeatures(toPrebuildFeatureWithNoName(features), null, null); }