How to index and search two different tables which are in same datasource using single solr instance(two different search fields no joins)

后端 未结 2 981
走了就别回头了
走了就别回头了 2021-02-03 16:05

I am new to solr. I have couple of questions on solr Indexing and searching:

  1. Can I configure to index two tables( no relationship 1. books and 2. computers and bot
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 16:46

    You can easily accomplish this with Solr, just take a good read at the DataImportHandler: http://wiki.apache.org/solr/DataImportHandler and to this example: http://wiki.apache.org/solr/MultipleIndexes

    Then do some googleing around for specific examples about entities. Basically, your data-config.xml should like something like this (not tested):

    
    
    
        
    

    Use the template to separate the two entities and define the category field as a string in your schema.xml. Also, make sure you pay attention to how you set the unique id parameter, some info for this specific topic is here: http://lucene.472066.n3.nabble.com/Indexing-multiple-entities-td504464.html and also check here: http://search.lucidimagination.com/search/document/f84c3abf7e859be1/dataimporthanlder_multiple_entities_will_step_into_each_other

    With this approach you have the two sets of data in the same index, in case you want them to work for two separate search boxes, you could simply run your searches like:

    myquery AND category:(books) <--- this would only get you the results from the books or this other one would only get you the computers results---> myquery AND category:(computers). Hope it helps. And for your pdf questions, I believe you have to use Apache's Tika module, I won't be of much help in here as i haven't used it myself, but here's the link: http://wiki.apache.org/solr/TikaEntityProcessor

提交回复
热议问题