Giter Site home page Giter Site logo

Comments (3)

adelapena avatar adelapena commented on August 16, 2024

Hi,

I think that most of the problems are because you are using a string mapper for adresse_1_destinataire column. This kind of mapper uses a KeywordAnalyzer that generates a single token per column value. Maybe using a text mapper with a language aware analyzer would be more appropriate:

CREATE CUSTOM INDEX lt_lucene_index ON vision_dev.lt (lucene) 
USING 'com.stratio.cassandra.lucene.Index'
WITH OPTIONS = {
   'refresh_seconds' : '10',
   'schema' : '{
       fields : {
           adresse_1_destinataire : {type:"text", analyzer:"french"},
           adresse_1_expediteur : {type:"text", analyzer:"french"},
           adresse_2_destinataire : {type:"text", analyzer:"french"},
           adresse_2_expediteur : {type:"text", analyzer:"french"},
           date_depot_lt : {type : "date", pattern : "yyyy-MM-dd"}
       }
   }'
};

Let's go through your example using string mapper:

Fuzzy

Fuzzy queries allows specifying the number of max allowed editions. This value, due to Lucene limitations, can't be greater than 2, which is also the default value. The query:

select ref_expediteur, adresse_1_destinataire 
from vision_dev.lt 
where lucene = '
            {filter : {type:"range", field:"date_depot_lt", lower:"2015-01-25", upper:"2015-04-01"},  
             query  :  {type:"fuzzy", field:"adresse_1_destinataire", value:"15 RUE DANIEL COGNAC"}}';

contains 3 editions (3 deleted characters) so no row is matched. A max of 2 editions could seem a strong limitation, but it seems to be enough when dealing with tokenized text, which is the common use case of fuzzy queries.

Match

Match queries find exact token matches. The query

select ref_expediteur, adresse_1_destinataire 
from vision_dev.lt 
where lucene = '
            {filter : {type:"range", field:"date_depot_lt", lower:"2015-01-25", upper:"2015-04-01"},  
             query  :  {type:"match", field:"adresse_1_destinataire", value:"COGNAC"}}';

does not return results because the column value 15 RUE DANIEL DE COGNAC has been translated to a single token by the analyzer. However, if you had used the french analyzer, then the text would have been translated to the tokens 15,rue,danieland cognac and you would have found results.

Phrase

The same thing happens with the phrase query:

select ref_expediteur, adresse_1_destinataire 
from vision_dev.lt 
where lucene = '
            {filter : {type:"range", field:"date_depot_lt", lower:"2015-01-25", upper:"2015-04-01"},  
             query  :  {type:"phrase", field:"adresse_1_destinataire", value:"15 RUE DANIEL COGNAC", slop:2}}';

The text is not tokenized and the purposed phrase query is trying to find rows/documents with the tokens 15,rue,danieland cognac whereas all the rows contain the single token 15 RUE DANIEL DE COGNAC.

I hope you find it useful.

from cassandra-lucene-index.

adejanovski avatar adejanovski commented on August 16, 2024

I totally missed the distinction between "string" and "text" in the index definition.
It works perfectly now !!

This project is a wonderful addon to Cassandra, which is so painful for building search engines, and now that the fork is not necessary anymore, it is way more convenient.

Thank you very much !

from cassandra-lucene-index.

Hervian avatar Hervian commented on August 16, 2024

@adejanovski
Can you share your solution (index creation statement + query)?
I am trying to use the plugin to create an address autocomplete function, but my fuzzy search does not work as expected.

from cassandra-lucene-index.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.