Field having multiple distinct values

前端 未结 3 971
抹茶落季
抹茶落季 2020-12-13 19:24

Am building a \"Book search\" API using Lucene. I need to index Book Name,Author, and Book category fields in Lucene index.

A single book can fall under multiple dis

3条回答
  •  臣服心动
    2020-12-13 20:08

    I would use Solr instead - it's built on Lucene and managed by the ASF, but is much, much easier to use than Lucene, especially for newcomers.

    If offers pretty much all the mainline features of Lucene (certainly everything you'll need for the project you describe), plus extra things like snapshotting, replication, schemas, ...

    In Solr, you would simply define the fields you want to index something like this in schema.xml:

    
    
    
    
    

    Note that the multiValued='true' attribute lets you effective pass an array or list to this field, which gets split and indexed nicely by Solr.

    Once you have this, start up Solr and you can ask queries like "book_authors:Hemingway" or "book_categories:Romance book_categories:Mills".

    There are several query handlers pre-written and configured for you to do things like parse complex queries (fuzzy matches, boolean operations, scoring boosts, ...), and as Solr's API is exposed over HTTP, all this is wrapped by a number of client libraries, so you don't need to handle the low-level details of crafting queries yourself.

    There is lots of great documentation on their website to get you started.

提交回复
热议问题