rnewson / couchdb-lucene

Enables full-text searching of CouchDB documents using Lucene
Apache License 2.0
769 stars 145 forks source link

new Ngram analyzer feature not working #211

Closed emig closed 9 years ago

emig commented 9 years ago

Hi, thanks for this great plugin!. I would like to report a bug

Given:

  {
   "_id": "3bd1ab0822370b35d9f6a28957000a05",
   "_rev": "2-be83559507385e58c17f21579c468eee",
   "name": "hallo"
  }
{
  "_id": "_design/bla",
    "_rev": "16-209eff72f73365b3dd132e6f70f8bc31",
    "fulltext": {
      "all": {
        "index": "function(doc) { var ret=new Document(); ret.add(doc.name, {analyzer: \"ngram:{min:2,max:3}\"}); return ret }"
      }
    }
}

I get a full text match:

$ curl -X GET "http://localhost:5984/_fti/local/gin_call_centre_test/_design/bla/all?q=hallo&debug=true"

{
  "analyzer": "class org.apache.lucene.analysis.standard.StandardAnalyzer",
  "etag": "13b7785c5b279570",
  "fetch_duration": 3,
  "limit": 25,
  "plan": "TermQuery(default:hallo,boost=1.0)",
  "q": "default:hallo",
  "rows": [{
    "id": "3bd1ab0822370b35d9f6a28957000a05",
    "score": 1
  }],
  "search_duration": 1,
  "skip": 0,
  "total_rows": 1
}%

but no partial match, as expected if NGram Analyzer would be working:

$ curl -X GET "http://localhost:5984/_fti/local/gin_call_centre_test/_design/b la/all?q=llo&debug=true"

{
  "analyzer": "class org.apache.lucene.analysis.standard.StandardAnalyzer",
  "etag": "13b7785c5b279570",
  "fetch_duration": 0,
  "limit": 25,
  "plan": "TermQuery(default:llo,boost=1.0)",
  "q": "default:llo",
  "rows": [],
  "search_duration": 0,
  "skip": 0,
  "total_rows": 0
}%
emig commented 9 years ago

I completely misunderstood the usage of analyzer, analyzer is defined in a couchdb document. Closing, not a bug.

rnewson commented 9 years ago

:)