org.apache.lucene.util.ToStringUtils Java Examples

The following examples show how to use org.apache.lucene.util.ToStringUtils. 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: BlendedTermQuery.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public String toString(String field) {
    StringBuilder builder = new StringBuilder("blended(terms:[");
    for (int i = 0; i < terms.length; ++i) {
        builder.append(terms[i]);
        float boost = 1f;
        if (boosts != null) {
            boost = boosts[i];
        }
        builder.append(ToStringUtils.boost(boost));
        builder.append(", ");
    }
    if (terms.length > 0) {
        builder.setLength(builder.length() - 2);
    }
    builder.append("])");
    builder.append(ToStringUtils.boost(getBoost()));
    return builder.toString();
}
 
Example #2
Source File: TermQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Prints a user-readable version of this query. */
public String toString(String field) {
  StringBuffer buffer = new StringBuffer();
  if (!term.field().equals(field)) {
    buffer.append(term.field());
    buffer.append(":");
  }
  buffer.append(term.text());
  buffer.append(ToStringUtils.boost(getBoost()));
  return buffer.toString();
}
 
Example #3
Source File: DateFieldMapper.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(String s) {
    final StringBuilder sb = new StringBuilder();
    return sb.append(names().indexName()).append(':')
        .append(includeLower ? '[' : '{')
        .append((lowerTerm == null) ? "*" : lowerTerm.toString())
        .append(" TO ")
        .append((upperTerm == null) ? "*" : upperTerm.toString())
        .append(includeUpper ? ']' : '}')
        .append(ToStringUtils.boost(getBoost()))
        .toString();
}
 
Example #4
Source File: FiltersFunctionScoreQuery.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(String field) {
    StringBuilder sb = new StringBuilder();
    sb.append("function score (").append(subQuery.toString(field)).append(", functions: [");
    for (FilterFunction filterFunction : filterFunctions) {
        sb.append("{filter(").append(filterFunction.filter).append("), function [").append(filterFunction.function).append("]}");
    }
    sb.append("])");
    sb.append(ToStringUtils.boost(getBoost()));
    return sb.toString();
}
 
Example #5
Source File: FunctionScoreQuery.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(String field) {
    StringBuilder sb = new StringBuilder();
    sb.append("function score (").append(subQuery.toString(field)).append(",function=").append(function).append(')');
    sb.append(ToStringUtils.boost(getBoost()));
    return sb.toString();
}
 
Example #6
Source File: 1139461_WildcardQuery_0_s.java    From coming with MIT License 5 votes vote down vote up
/** Prints a user-readable version of this query. */
@Override
public String toString(String field) {
  StringBuilder buffer = new StringBuilder();
  if (!term.field().equals(field)) {
    buffer.append(term.field());
    buffer.append(":");
  }
  buffer.append(term.text());
  buffer.append(ToStringUtils.boost(getBoost()));
  return buffer.toString();
}
 
Example #7
Source File: 1139461_WildcardQuery_0_t.java    From coming with MIT License 5 votes vote down vote up
/** Prints a user-readable version of this query. */
@Override
public String toString(String field) {
  StringBuilder buffer = new StringBuilder();
  if (!term.field().equals(field)) {
    buffer.append(term.field());
    buffer.append(":");
  }
  buffer.append(term.text());
  buffer.append(ToStringUtils.boost(getBoost()));
  return buffer.toString();
}
 
Example #8
Source File: ImageHashQuery.java    From elasticsearch-image with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(String field) {
    StringBuilder buffer = new StringBuilder();
    if (!term.field().equals(field)) {
        buffer.append(term.field());
        buffer.append(":");
    }
    buffer.append(term.text());
    buffer.append(";");
    buffer.append(luceneFieldName);
    buffer.append(",");
    buffer.append(lireFeature.getClass().getSimpleName());
    buffer.append(ToStringUtils.boost(getBoost()));
    return buffer.toString();
}
 
Example #9
Source File: ImageHashLimitQuery.java    From elasticsearch-image with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(String field) {
    StringBuilder buffer = new StringBuilder();
    buffer.append(hashFieldName);
    buffer.append(",");
    buffer.append(Arrays.toString(hashes));
    buffer.append(",");
    buffer.append(maxResult);
    buffer.append(",");
    buffer.append(luceneFieldName);
    buffer.append(",");
    buffer.append(lireFeature.getClass().getSimpleName());
    buffer.append(ToStringUtils.boost(getBoost()));
    return buffer.toString();
}
 
Example #10
Source File: ImageQuery.java    From elasticsearch-image with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(String field) {
    StringBuilder buffer = new StringBuilder();
    buffer.append(luceneFieldName);
    buffer.append(",");
    buffer.append(lireFeature.getClass().getSimpleName());
    buffer.append(ToStringUtils.boost(getBoost()));
    return buffer.toString();
}
 
Example #11
Source File: ChildrenQuery.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public String toString(String field) {
    int max = maxChildren == 0 ? Integer.MAX_VALUE : maxChildren;
    return "ChildrenQuery[min(" + Integer.toString(minChildren) + ") max(" + Integer.toString(max) + ")of " + childType + "/"
            + parentType + "](" + childQuery.toString(field) + ')' + ToStringUtils.boost(getBoost());
}
 
Example #12
Source File: ParentQuery.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public String toString(String field) {
    return "ParentQuery[" + parentType + "](" + parentQuery.toString(field) + ')' + ToStringUtils.boost(getBoost());
}
 
Example #13
Source File: MultiPhrasePrefixQuery.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public final String toString(String f) {
    StringBuilder buffer = new StringBuilder();
    if (field == null || !field.equals(f)) {
        buffer.append(field);
        buffer.append(":");
    }

    buffer.append("\"");
    Iterator<Term[]> i = termArrays.iterator();
    while (i.hasNext()) {
        Term[] terms = i.next();
        if (terms.length > 1) {
            buffer.append("(");
            for (int j = 0; j < terms.length; j++) {
                buffer.append(terms[j].text());
                if (j < terms.length - 1) {
                    if (i.hasNext()) {
                        buffer.append(" ");
                    } else {
                        buffer.append("* ");
                    }
                }
            }
            if (i.hasNext()) {
                buffer.append(") ");
            } else {
                buffer.append("*)");
            }
        } else {
            buffer.append(terms[0].text());
            if (i.hasNext()) {
                buffer.append(" ");
            } else {
                buffer.append("*");
            }
        }
    }
    buffer.append("\"");

    if (slop != 0) {
        buffer.append("~");
        buffer.append(slop);
    }

    buffer.append(ToStringUtils.boost(getBoost()));

    return buffer.toString();
}
 
Example #14
Source File: AllTermQuery.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public String toString(String field) {
    return new TermQuery(term).toString(field) + ToStringUtils.boost(getBoost());
}