Limit couchdb-lucene results to key / specific fields? map?

I have a pretty simple question.

I use couchdb-lucene to find the full text of my documents.

My docs have the following fields:

_id

_rev

docID (unique identifier of a document from our system)

title (document title)

content (document body)

userID (user who owns the document)

My design document is as follows:

{
   "_id": "_design/lucene",
   "_rev": "10-770b7044393e067b7024a896ccf3c502",
   "fulltext": {
       "by_all": {
           "index": "function(doc) { var ret=new Document(); ret.add(doc.title); ret.add(doc.content); return ret }"
       },
       "by_title": {
           "index": "function(doc) { var ret=new Document(); ret.add(doc.title); return ret }"
       }
   }
}

I could not figure out how to return the docID as part of the results, so I just made the identifier equal to docID, but I would like to understand how to return the docID since the project document above returns the invoice and document ID. I would prefer not to set the identifier with the same value as the docID in order to access it.

When I run the query, for example:

: 5984/Foo/_fti/_design/Lucene/ = by_all ~ 0.5f

, "", , "" , ? ?

- :

: 5984/Foo/_fti/_design/Lucene/ = by_all ~ 0.5f & = 123

: localhost: 5984/foo/_fti/_design/lucene/by_all? q = example ~ 0.5f, , , , ? , .

!

p.s. , : "map": "function (doc) {emit (doc._id, doc._rev)}"

? couchdb-lucene? , , , , ? , ... , , CouchDB, Lucene, .

!

+3
1

, .

function(doc) {
  var ret=new Document();
  ret.add(doc.title);
  ret.add(doc.content});
  ret.add(doc.userID, {"field":"userID"});
  ret.add(doc.docID, {"field":"docID","store":"yes"});
  return ret;
}

;

localhost:5984/foo/_fti/_design/lucene/by_all?q=example%20AND%20userID:123

"" , 123. , docID .

, .

+3

Source: https://habr.com/ru/post/1794597/


All Articles