Comments (3)
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
,daniel
and 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
,daniel
and cognac
whereas all the rows contain the single token 15 RUE DANIEL DE COGNAC
.
I hope you find it useful.
from cassandra-lucene-index.
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.
@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)
- Altering UDTs cause ArrayIndexOutOfBoundsException in ColumnsMapper HOT 14
- Unable to find custom indexer in Cassandra 3.11.2 HOT 1
- Support cassandra-3.11.3
- When a column from the index is used in a predicate cassandra always returns 0 records.
- ArrayIndexOutOfBounds with collections of UDTs HOT 2
- Request timeout error while retrieving data using Stratio-cassandra-lucene-index
- Can't retrieve Many records and count(*)
- Indexing Status
- Index text field as JSON HOT 2
- cassandra search - Returning the score of each result HOT 1
- Query maps where value is case_sensitive=false
- Support for Cassandra 4
- Custom Query
- Exception encountered during startup
- Upgrade to JTS 1.16.1
- Lucene Index Empty after upgrade
- Lucene Index with Cassandra SSL
- Another CQL "date" type: No results
- JVM segfault in ~StubRoutines::updateBytesCRC32 during commit() HOT 1
- Cassandra secondary lucene index rebuild is very slowly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cassandra-lucene-index.