Fuzzy search

Find terms with similar spelling:

Type of query

solr_query value

Description

Similar spelling

'Kenya~'

The Solr fuzzy search syntax uses the Damerau-Levenshtein Distance algorithm to determine similarity of spelling based on distance. A range of 0-2 can be specified, such as Kenya~1. Default distance: 2

Proximity search

'"football Bolivia"~10'

Searches for football and Bolivia within 10 words of each other.

Range searches

'title:[football TO soccer}'

Supports both inclusive and exclusive bounds using square brackets and curly braces, respectively.

Term boosting

'"football"^4 "soccer"'

By default, the boost factor is 1. Must be a positive number.

  • The following example shows a search for Science in the title field using the default distance 2:

    SELECT title FROM solr WHERE solr_query = 'title:Science~';

    The first row is unexpected, given the difference of ci in Science to p in Spence; the letters are similar, but the meaning is dissimilar. The fifth row has Schenck, even more dissimilar, although within the distance of 2 just like Spence.

     title
    ------------------------------------------------------------------------
                                                              Aitken Spence
                                          African Journal of Marine Science
                                African Journal of Range and Forage Science
                                  African Journal of Science and Technology
                                               Maarten Schenck van Nydeggen
                                   African Journal of Neurological Sciences
                               National Natural Science Foundation of China
                               China Association for Science and Technology
     Philippine Science High School Cordillera Administrative Region Campus
               African Journal of Library, Archives and Information Science
    
    (10 rows)
  • This example shows a search for Science in the title field using a smaller distance of 1, which produces a more accurate result:

    SELECT title FROM solr WHERE solr_query = 'title:Science~1';
     title
    ------------------------------------------------------------------------
                                          African Journal of Marine Science
                                African Journal of Range and Forage Science
                                  African Journal of Science and Technology
                                   African Journal of Neurological Sciences
                               National Natural Science Foundation of China
                               China Association for Science and Technology
     Philippine Science High School Cordillera Administrative Region Campus
               African Journal of Library, Archives and Information Science
    
    (8 rows)

    In this case, only the title with Sciences is different from all the other titles with Science in the title.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com