rnewson/couchdb-lucene — Issue #154: cannot search in fields with dash
Author: pwde
Created: 2012-03-07 08:58:18+00:00
State: open

Hello Robert,

first, thanks for couchdb-lucene. We used couchdb and couchdb-lucene for the last 6 month.

But I run into a strange issue when using lucene-fiels with dash AND without wildcards:

curl -X GET http://127.0.0.1:5984/ndb/_fti/_design/search/ndb_obj?q=attr-with-dash:value
{"reason":"Bad query syntax: Cannot parse 'attr-with-dash:value': Field 'attr-with-dash' not recognized.","code":400}

When include a wildcard, then I got the result:

curl -X GET http://127.0.0.1:5984/ndb/_fti/_design/search/ndb_obj?q=attr-with-dash:valu*
{"limit":50,"etag":"6ff112e4123","fetch_duration":0,"q":"attr-with-dash:valu*","search_duration":0,"total_rows":1,"skip":0,"rows":[{"id":"04b861b48b6fe810931ff34ec4be3577","score":1}]}

Using lucene-fileds without dashes, I got the expected results:

curl -X GET http://127.0.0.1:5984/ndb/_fti/_design/search/ndb_obj?q=attrWithoutDash:value
{"limit":50,"etag":"6ff112e4123","fetch_duration":0,"q":"attrWithoutDash:value","search_duration":0,"total_rows":1,"skip":0,"rows":[{"id":"04b861b48b6fe810931ff34ec4be3577","score":8.047951698303223}]}

The related doc:
{
"_id": "04b861b48b6fe810931ff34ec4be3577",
"_rev": "5-ab29da369465b362a76c5aa16e755162",
"template": "test-search",
"attr": {
"attrWithoutDash": [
"value"
],
"attr-with-dash": [
"value"
]
}
}

The search function:
function(doc) {
var ret = new Document();
if (doc.attr) {
for (var aname in doc.attr) {
var values = doc.attr[aname];
for (var i=0; i