incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Barnes <mrtr...@gmail.com>
Subject Re: couchdb-lucene fulltextsearch
Date Sat, 13 Feb 2010 23:31:10 GMT
Read through the documentation at
http://github.com/rnewson/couchdb-lucene
(Keep scrolling further down the page)

When you call rec.add() (And you can call add() more than once per 
function), there is an optional second argument to set the indexing options:

The two that you'd probably find useful are:

doc.add(doc.subject, {"field":"subject"});
If you explicitly name the field, your query must look like q=subject:Foo

and
doc.add(doc.subject, {"stored":"yes"});
This stores the value inside the result - so that it will be shown even 
without include_docs=true.
(If you want the field shown but don't want to search on it, also add 
"index":"not_analyzed" to the options object.)

The options are shown on the web page in the "The Defaults Object" table 
- further on are lots of examples.

-Patrick


On 14/02/2010 3:48 AM, km wrote:
> Hi all,
> I am working with couchdb v0.10.0 + couchdb-lucene v0.4
> I have a  design document (from the docs) for a couchdb database with
> fulltext search indexes
>
> {
>    "_id":"_design/lucene",
>    "_rev":" some rev id ... ",
>
>    "fulltext":{
>        "by_name":{
>        "index":"function(doc){var rec = new Document(); rec.add(doc.name);
> return rec;}"
>        }
>    }
> }
>
> now using this, i query
> curl http://localhost:5984/mydb/_fti/lucene/by_name?q='john'
>
> so far so good and I retrive one record like this
>   {"q":"john","etag":"126bc75d913","view_sig":"ffe984900a27786e627594907565e3aa","skip":0,"limit":25,"total_rows":1,"search_duration":0,"fetch_duration":0,"rows":[{"id":"0a08997ba60937ce49ed6b9b4eb11369","score":8.580954551696777}]}
>
> But how  do I retrieve  some of keys and their values from the documents
> matched ?
> Ofcourse I can attach an "include_docs=true" to the query param, But that
> returns entire document to the client which is not desired - (big documents)
> .
>
>
> do I need to have a map function for this ? and where should i place it ?
> pls enlighten.
>
> thanks
> Krishna
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

Mime
View raw message