Full-text search in CouchDB

后端 未结 3 1787
我在风中等你
我在风中等你 2020-12-13 10:48

I have a problem and hope to get an answer from you :-)

So, I took geonames.org and imported all their data of German cities with all districts.

If I enter \

3条回答
  •  悲哀的现实
    2020-12-13 11:45

    If I understand your problem right, probably all you need is already built in the CouchDB.

    1. To get a range of documents with names beginning with e.g. "Ham". You may use a request with a string range: startkey="Ham"&endkey="Ham\ufff0"
    2. If you need a more comprehensive search, you may create a view containing names of other places as keys. So you again can query ranges using the technique above.

    Here is a view function to make this:

    function(doc) {
        for (var name in doc.places) {
            emit(name, doc._id);
        }
    }
    

    Also see the CouchOne blog post about CouchDB typeahead and autocomplete search and this discussion on the mailing list about CouchDB autocomplete.

提交回复
热议问题