cannot search in fields with dash #154

Closed
pwde opened this Issue Mar 7, 2012 · 3 comments

Comments

Projects
None yet
2 participants

pwde commented Mar 7, 2012

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<values.length; i++) {
ret.add(values[i], {'field':aname});
}
}
}
return ret;
}

May be I do something wrong...

Best regards,
Peter.

Owner

rnewson commented Mar 7, 2012

It's a bug. There's some post-processing for term queries (your "foo", but not your "foo*") that examines the field name, looking for the type ("foo", for example). That examination does not expect dashes in the field name. I can easily fix that.

pwde commented Mar 7, 2012

a fix would be great. :-)

rnewson closed this in 3f20378 Mar 7, 2012

pwde commented Mar 7, 2012

thanks. successfully verified.

Regards,
Peter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment