Advanced term and phrase searches

Procedure

  • Find terms with like spelling:

    The Solr fuzzy search syntax uses the Damerau-Levenshtein Distance algorithm to determine similarity of spelling based on distance. The default distance is 2. Change the distance by specifying 0-2 after the tilde (Kenya~1).

    Type of query solr_query value Description

    Like spelling

    'Kenya~'

    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 using the default distance 2:

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

    The first row is unexpected, the letters are close together but the meaning is dissimilar.

     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)
  • The following example shows a search for science using a smaller distance:

    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)

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