fix #2568 add query parameters
This commit is contained in:
parent
fb93dc4ea6
commit
c1bacf14a7
3 changed files with 162 additions and 9 deletions
|
@ -511,45 +511,58 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected QueryBuilder convertPrefixQuery(final QueryContext context, final PrefixQuery prefixQuery, final float boost) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String field = getSearchField(context, prefixQuery.getField());
|
||||
if (Constants.DEFAULT_FIELD.equals(field)) {
|
||||
context.addFieldLog(field, prefixQuery.getPrefix().text());
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders
|
||||
.matchPhrasePrefixQuery(f, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(b * boost));
|
||||
return buildDefaultQueryBuilder(
|
||||
(f, b) -> QueryBuilders.matchPhrasePrefixQuery(f, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(b * boost)
|
||||
.maxExpansions(fessConfig.getQueryPrefixExpansionsAsInteger()).slop(fessConfig.getQueryPrefixSlopAsInteger()));
|
||||
}
|
||||
if (!isSearchField(field)) {
|
||||
final String query = prefixQuery.getPrefix().toString();
|
||||
final String origQuery = toLowercaseWildcard(query);
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, query);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.matchPhrasePrefixQuery(f, origQuery).boost(b * boost));
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.matchPhrasePrefixQuery(f, origQuery).boost(b * boost)
|
||||
.maxExpansions(fessConfig.getQueryPrefixExpansionsAsInteger()).slop(fessConfig.getQueryPrefixSlopAsInteger()));
|
||||
}
|
||||
context.addFieldLog(field, prefixQuery.getPrefix().text());
|
||||
if (notAnalyzedFieldSet.contains(field)) {
|
||||
return QueryBuilders.prefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
} else {
|
||||
return QueryBuilders.matchPhrasePrefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
return QueryBuilders.matchPhrasePrefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost)
|
||||
.maxExpansions(fessConfig.getQueryPrefixExpansionsAsInteger()).slop(fessConfig.getQueryPrefixSlopAsInteger());
|
||||
}
|
||||
}
|
||||
|
||||
protected QueryBuilder convertFuzzyQuery(final QueryContext context, final FuzzyQuery fuzzyQuery, final float boost) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final Term term = fuzzyQuery.getTerm();
|
||||
final String field = getSearchField(context, term.field());
|
||||
// TODO fuzzy value
|
||||
if (Constants.DEFAULT_FIELD.equals(field)) {
|
||||
context.addFieldLog(field, term.text());
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.fuzzyQuery(f, term.text())
|
||||
.fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits())).boost(b * boost));
|
||||
return buildDefaultQueryBuilder(
|
||||
(f, b) -> QueryBuilders.fuzzyQuery(f, term.text()).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits()))
|
||||
.boost(b * boost).maxExpansions(fessConfig.getQueryFuzzyExpansionsAsInteger())
|
||||
.prefixLength(fessConfig.getQueryFuzzyPrefixLengthAsInteger())
|
||||
.transpositions(Constants.TRUE.equalsIgnoreCase(fessConfig.getQueryFuzzyTranspositions())));
|
||||
}
|
||||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, term.text());
|
||||
return QueryBuilders.fuzzyQuery(field, term.text()).boost(boost).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits()));
|
||||
return QueryBuilders.fuzzyQuery(field, term.text()).boost(boost).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits()))
|
||||
.maxExpansions(fessConfig.getQueryFuzzyExpansionsAsInteger())
|
||||
.prefixLength(fessConfig.getQueryFuzzyPrefixLengthAsInteger())
|
||||
.transpositions(Constants.TRUE.equalsIgnoreCase(fessConfig.getQueryFuzzyTranspositions()));
|
||||
}
|
||||
final String origQuery = fuzzyQuery.toString();
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, origQuery);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder(
|
||||
(f, b) -> QueryBuilders.fuzzyQuery(f, origQuery).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits())).boost(b * boost));
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.fuzzyQuery(f, origQuery)
|
||||
.fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits())).boost(b * boost)
|
||||
.maxExpansions(fessConfig.getQueryFuzzyExpansionsAsInteger()).prefixLength(fessConfig.getQueryFuzzyPrefixLengthAsInteger())
|
||||
.transpositions(Constants.TRUE.equalsIgnoreCase(fessConfig.getQueryFuzzyTranspositions())));
|
||||
}
|
||||
|
||||
protected QueryBuilder convertTermRangeQuery(final QueryContext context, final TermRangeQuery termRangeQuery, final float boost) {
|
||||
|
|
|
@ -1025,6 +1025,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. true */
|
||||
String QUERY_BOOST_FUZZY_CONTENT_TRANSPOSITIONS = "query.boost.fuzzy.content.transpositions";
|
||||
|
||||
/** The key of the configuration. e.g. 50 */
|
||||
String QUERY_PREFIX_EXPANSIONS = "query.prefix.expansions";
|
||||
|
||||
/** The key of the configuration. e.g. 0 */
|
||||
String QUERY_PREFIX_SLOP = "query.prefix.slop";
|
||||
|
||||
/** The key of the configuration. e.g. 0 */
|
||||
String QUERY_FUZZY_prefix_length = "query.fuzzy.prefix_length";
|
||||
|
||||
/** The key of the configuration. e.g. 50 */
|
||||
String QUERY_FUZZY_EXPANSIONS = "query.fuzzy.expansions";
|
||||
|
||||
/** The key of the configuration. e.g. true */
|
||||
String QUERY_FUZZY_TRANSPOSITIONS = "query.fuzzy.transpositions";
|
||||
|
||||
/** The key of the configuration. e.g. label */
|
||||
String QUERY_FACET_FIELDS = "query.facet.fields";
|
||||
|
||||
|
@ -4766,6 +4781,80 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
boolean isQueryBoostFuzzyContentTranspositions();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.prefix.expansions'. <br>
|
||||
* The value is, e.g. 50 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryPrefixExpansions();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.prefix.expansions' as {@link Integer}. <br>
|
||||
* The value is, e.g. 50 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getQueryPrefixExpansionsAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.prefix.slop'. <br>
|
||||
* The value is, e.g. 0 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryPrefixSlop();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.prefix.slop' as {@link Integer}. <br>
|
||||
* The value is, e.g. 0 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getQueryPrefixSlopAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.fuzzy.prefix_length'. <br>
|
||||
* The value is, e.g. 0 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryFuzzyPrefixLength();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.fuzzy.prefix_length' as {@link Integer}. <br>
|
||||
* The value is, e.g. 0 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getQueryFuzzyPrefixLengthAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.fuzzy.expansions'. <br>
|
||||
* The value is, e.g. 50 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryFuzzyExpansions();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.fuzzy.expansions' as {@link Integer}. <br>
|
||||
* The value is, e.g. 50 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getQueryFuzzyExpansionsAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.fuzzy.transpositions'. <br>
|
||||
* The value is, e.g. true <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryFuzzyTranspositions();
|
||||
|
||||
/**
|
||||
* Is the property for the key 'query.fuzzy.transpositions' true? <br>
|
||||
* The value is, e.g. true <br>
|
||||
* @return The determination, true or false. (if not found, exception but basically no way)
|
||||
*/
|
||||
boolean isQueryFuzzyTranspositions();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.facet.fields'. <br>
|
||||
* The value is, e.g. label <br>
|
||||
|
@ -8642,6 +8731,46 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return is(FessConfig.QUERY_BOOST_FUZZY_CONTENT_TRANSPOSITIONS);
|
||||
}
|
||||
|
||||
public String getQueryPrefixExpansions() {
|
||||
return get(FessConfig.QUERY_PREFIX_EXPANSIONS);
|
||||
}
|
||||
|
||||
public Integer getQueryPrefixExpansionsAsInteger() {
|
||||
return getAsInteger(FessConfig.QUERY_PREFIX_EXPANSIONS);
|
||||
}
|
||||
|
||||
public String getQueryPrefixSlop() {
|
||||
return get(FessConfig.QUERY_PREFIX_SLOP);
|
||||
}
|
||||
|
||||
public Integer getQueryPrefixSlopAsInteger() {
|
||||
return getAsInteger(FessConfig.QUERY_PREFIX_SLOP);
|
||||
}
|
||||
|
||||
public String getQueryFuzzyPrefixLength() {
|
||||
return get(FessConfig.QUERY_FUZZY_prefix_length);
|
||||
}
|
||||
|
||||
public Integer getQueryFuzzyPrefixLengthAsInteger() {
|
||||
return getAsInteger(FessConfig.QUERY_FUZZY_prefix_length);
|
||||
}
|
||||
|
||||
public String getQueryFuzzyExpansions() {
|
||||
return get(FessConfig.QUERY_FUZZY_EXPANSIONS);
|
||||
}
|
||||
|
||||
public Integer getQueryFuzzyExpansionsAsInteger() {
|
||||
return getAsInteger(FessConfig.QUERY_FUZZY_EXPANSIONS);
|
||||
}
|
||||
|
||||
public String getQueryFuzzyTranspositions() {
|
||||
return get(FessConfig.QUERY_FUZZY_TRANSPOSITIONS);
|
||||
}
|
||||
|
||||
public boolean isQueryFuzzyTranspositions() {
|
||||
return is(FessConfig.QUERY_FUZZY_TRANSPOSITIONS);
|
||||
}
|
||||
|
||||
public String getQueryFacetFields() {
|
||||
return get(FessConfig.QUERY_FACET_FIELDS);
|
||||
}
|
||||
|
@ -10178,6 +10307,11 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.QUERY_BOOST_FUZZY_CONTENT_EXPANSIONS, "10");
|
||||
defaultMap.put(FessConfig.QUERY_BOOST_FUZZY_CONTENT_prefix_length, "0");
|
||||
defaultMap.put(FessConfig.QUERY_BOOST_FUZZY_CONTENT_TRANSPOSITIONS, "true");
|
||||
defaultMap.put(FessConfig.QUERY_PREFIX_EXPANSIONS, "50");
|
||||
defaultMap.put(FessConfig.QUERY_PREFIX_SLOP, "0");
|
||||
defaultMap.put(FessConfig.QUERY_FUZZY_prefix_length, "0");
|
||||
defaultMap.put(FessConfig.QUERY_FUZZY_EXPANSIONS, "50");
|
||||
defaultMap.put(FessConfig.QUERY_FUZZY_TRANSPOSITIONS, "true");
|
||||
defaultMap.put(FessConfig.QUERY_FACET_FIELDS, "label");
|
||||
defaultMap.put(FessConfig.QUERY_FACET_FIELDS_SIZE, "100");
|
||||
defaultMap.put(FessConfig.QUERY_FACET_FIELDS_min_doc_count, "1");
|
||||
|
|
|
@ -538,6 +538,12 @@ query.boost.fuzzy.content.expansions=10
|
|||
query.boost.fuzzy.content.prefix_length=0
|
||||
query.boost.fuzzy.content.transpositions=true
|
||||
|
||||
query.prefix.expansions=50
|
||||
query.prefix.slop=0
|
||||
query.fuzzy.prefix_length=0
|
||||
query.fuzzy.expansions=50
|
||||
query.fuzzy.transpositions=true
|
||||
|
||||
# facet
|
||||
query.facet.fields=label
|
||||
query.facet.fields.size=100
|
||||
|
|
Loading…
Add table
Reference in a new issue