List of usage examples for org.apache.lucene.queryparser.flexible.core.nodes FuzzyQueryNode getPrefixLength
public int getPrefixLength()
From source file:com.sindicetech.siren.qparser.keyword.builders.concise.ConciseNodeFuzzyQueryNodeBuilder.java
License:Open Source License
@Override public NodeQuery build(final QueryNode queryNode) throws QueryNodeException { if (conf.has(ConciseKeywordQueryConfigHandler.ConciseKeywordConfigurationKeys.ATTRIBUTE)) { final String attribute = conf .get(ConciseKeywordQueryConfigHandler.ConciseKeywordConfigurationKeys.ATTRIBUTE); FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode; // Prepend the attribute to the query term ConciseNodeBuilderUtil.prepend(builder, attribute, fuzzyNode); // Update the prefix length: must account for the attribute length plus the delimiter character fuzzyNode.setPrefixLength(fuzzyNode.getPrefixLength() + attribute.length() + 1); }//from w w w. ja va 2 s.co m // Delegate the build to parent class return super.build(queryNode); }
From source file:com.sindicetech.siren.qparser.keyword.builders.NodeFuzzyQueryNodeBuilder.java
License:Open Source License
public NodeQuery build(QueryNode queryNode) throws QueryNodeException { FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode; String text = fuzzyNode.getTextAsString(); int numEdits = FuzzyQuery.floatToEdits(fuzzyNode.getSimilarity(), text.codePointCount(0, text.length())); NodeFuzzyQuery fuzzyQuery = new NodeFuzzyQuery( new Term(fuzzyNode.getFieldAsString(), fuzzyNode.getTextAsString()), numEdits, fuzzyNode.getPrefixLength()); // assign the datatype. We must always have a datatype assigned. fuzzyQuery.setDatatype((String) queryNode.getTag(DatatypeQueryNode.DATATYPE_TAGID)); // if it is tagged as a span query if (fuzzyNode.getTag(QueryTypeProcessor.QUERYTYPE_TAG) == QueryTypeProcessor.SPAN_QUERYTYPE) { return new MultiTermSpanQuery<>(fuzzyQuery); } else {//www.j a v a 2 s .c o m return fuzzyQuery; } }
From source file:org.sindice.siren.qparser.keyword.builders.NodeFuzzyQueryNodeBuilder.java
License:Apache License
public NodeFuzzyQuery build(QueryNode queryNode) throws QueryNodeException { FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode; String text = fuzzyNode.getTextAsString(); int numEdits = FuzzyQuery.floatToEdits(fuzzyNode.getSimilarity(), text.codePointCount(0, text.length())); return new NodeFuzzyQuery(new Term(fuzzyNode.getFieldAsString(), fuzzyNode.getTextAsString()), numEdits, fuzzyNode.getPrefixLength()); }