Example usage for org.apache.solr.common.params SpellingParams SPELLCHECK_COUNT

List of usage examples for org.apache.solr.common.params SpellingParams SPELLCHECK_COUNT

Introduction

In this page you can find the example usage for org.apache.solr.common.params SpellingParams SPELLCHECK_COUNT.

Prototype

String SPELLCHECK_COUNT

To view the source code for org.apache.solr.common.params SpellingParams SPELLCHECK_COUNT.

Click Source Link

Document

The count of suggestions to return for each query term not in the index and/or dictionary.

Usage

From source file:org.phenotips.termrequester.db.solr.SolrDatabaseService.java

License:Open Source License

@Override
public List<Phenotype> searchPhenotypes(String text) throws IOException {
    checkUp();//from  w  w  w  . jav a 2  s .  c  o  m
    try {
        SolrQuery q = new SolrQuery();
        String escaped = ClientUtils.escapeQueryChars(text);
        q.add(CommonParams.Q, escaped);
        q.add(SpellingParams.SPELLCHECK_Q, text);
        q.add(DisMaxParams.PF,
                String.format("%s^20 %s^36 %s^100 %s^30 %s^15 %s^25 %s^70 %s^20 %s^3 %s^5", Schema.NAME,
                        Schema.NAME_SPELL, Schema.NAME_EXACT, Schema.NAME_PREFIX, Schema.SYNONYM,
                        Schema.SYNONYM_SPELL, Schema.SYNONYM_EXACT, Schema.SYNONYM_PREFIX, Schema.TEXT,
                        Schema.TEXT_SPELL));
        String qstring = String.format("%s^10 %s^18 %s^5 %s^6 %s^10 %s^3 %s^1 %s^2 %s^0.5", Schema.NAME,
                Schema.NAME_SPELL, Schema.NAME_STUB, Schema.SYNONYM, Schema.SYNONYM_SPELL, Schema.SYNONYM_STUB,
                Schema.TEXT, Schema.TEXT, Schema.TEXT_SPELL, Schema.TEXT_STUB);
        qstring = addStatusFilter(qstring, Phenotype.Status.SYNONYM);
        q.add(DisMaxParams.QF, qstring);
        q.add("spellcheck", Boolean.toString(true));
        q.add(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true));
        q.add(SpellingParams.SPELLCHECK_COUNT, "100");
        q.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "3");
        q.add("lowercaseOperators", Boolean.toString(false));
        q.add("defType", "edismax");
        QueryResponse resp = server.query(q);
        List<SolrDocument> results = resp.getResults();
        List<Phenotype> retval = new ArrayList<>(results.size());
        for (SolrDocument doc : results) {
            retval.add(mapper.fromDoc(doc));
        }
        return retval;
    } catch (SolrServerException e) {
        throw new IOException(e);
    }
}

From source file:org.phenotips.vocabulary.internal.solr.HumanPhenotypeOntology.java

License:Open Source License

private Map<String, String> getStaticSolrParams() {
    Map<String, String> params = new HashMap<>();
    params.put("spellcheck", Boolean.toString(true));
    params.put(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true));
    params.put(SpellingParams.SPELLCHECK_COUNT, "100");
    params.put(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "3");
    params.put("lowercaseOperators", Boolean.toString(false));
    params.put("defType", "edismax");
    return params;
}

From source file:org.phenotips.vocabulary.internal.solr.OncoTree.java

License:Open Source License

/**
 * Given a {@code query} object, adds global query parameters.
 *
 * @param query a {@link SolrQuery solr query} object
 *//* www .j a  v a 2s  .c  o m*/
private void addGlobalQueryParam(@Nonnull final SolrQuery query) {
    // Add global query parameters.
    query.set("spellcheck", Boolean.toString(true));
    query.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true));
    query.set(SpellingParams.SPELLCHECK_COUNT, "100");
    query.set(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "3");
    query.set("lowercaseOperators", Boolean.toString(false));
    query.set("defType", "edismax");
}

From source file:org.phenotips.vocabulary.internal.solr.OrphanetRareDiseaseOntology.java

License:Open Source License

/**
 * Given a {@code query} object, adds global query parameters.
 *
 * @param query a {@link SolrQuery solr query} object
 * @return the {@code query} with global query parameters added
 *///from www . ja  v  a2 s. c om
private SolrQuery addGlobalQueryParam(@Nonnull final SolrQuery query) {
    // Add global query parameters.
    query.set("spellcheck", Boolean.toString(true));
    query.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true));
    query.set(SpellingParams.SPELLCHECK_COUNT, "100");
    query.set(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "3");
    query.set("lowercaseOperators", Boolean.toString(false));
    query.set("defType", "edismax");
    return query;
}

From source file:org.springframework.data.solr.core.query.SpellcheckOptions.java

License:Apache License

/**
 * Specifies the maximum number of spelling suggestions to be returned.
 *
 * @param nr//from  w  w  w. j  a v a 2  s.  c o  m
 * @return
 */
public SpellcheckOptions count(long nr) {
    return createNewAndAppend(SpellingParams.SPELLCHECK_COUNT, nr);
}

From source file:org.springframework.data.solr.core.query.SpellcheckOptions.java

License:Apache License

/**
 * @return can be {@literal null}.
 */
@Nullable
public Long getCount() {
    return (Long) params.get(SpellingParams.SPELLCHECK_COUNT);
}