How to index and search for two different tables that are in the same data source using one instance of solr (two different search fields are not combined)

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

  • Can I set up indexing of two tables (there is no relationship between 1. books and 2. computers and both are in the same data source) if I want to have two search boxes. Is it possible to do something like defining two objects in one data-config.xml file

If yes, please let me know the steps.

I think we can use two different data-config.xml files. But you need to know how to configure in schema.xml and related changes.

  1. How to configure solr to index PDF and Mysql files on a single instance of solr.

Please help me and find out if there are any reference documents.

+3
xml indexing solr
source share
2 answers

2 different tables no relationship

Data-config.xml:

<document> <entity name="topic" transformer="TemplateTransformer" pk="topic_id" query="select topic_id,topic_title,creation_date,updation_date,vote_count,....."> <field column=" doc_id " template="TOPIC_${topic.topic_id} " /> <field column="doc_type " template="TOPIC " /> </entity> <entity name="product " transformer="TemplateTransformer " pk="product_id " query="SELECT product_id,..... "> <field column="doc_id " template="PRODUCT_${product.product_id} " /> <field column="doc_type " template="PRODUCT " /> <field column="product_supplier_id " name="product_supplier_id " /> <field column="supplier_product_code " name="supplier_product_code " /> <field column="product_display_name " name="product_display_name " /> </entity> </document> 

schema.xml:

  <schema> . . . <fields> <field name="doc_id" type="string" /> <field name="doc_type" type="string" /> <field name="catchall" type="string" stored="false" omitNorms="true" multiValued="true" /> <field name="topic_title" type="text_general" />. . . . </fields> <uniqueKey>doc_id</uniqueKey> <copyField source="*" dest="catchall" /> <!-- field for the QueryParser to use when an explicit fieldname is absent --> <defaultSearchField>catchall</defaultSearchField> </schema> 

Additional information - http://www.lucidimagination.com/blog/2011/02/12/solr-powered-isfdb-part-4/

there should not be a field above or there may be a problem with indexing

you can request a browser, for example http://localhost:8080/solr/select/?q=*:*&fq=doc_type:PRODUCT

+5
source share

You can easily do this with Solr, just read carefully in DataImportHandler: http://wiki.apache.org/solr/DataImportHandler and for this example: http://wiki.apache.org/solr/MultipleIndexes

Then follow some steps for specific examples about objects. Basically, your data-config.xml should like something like this (not verified):

 <entity name="books" transformer="TemplateTransformer" dataSource="myindex" query="SELECT * FROM t_books";> <field column="category" template="books" name="category"/></entity> <entity name="computers" dataSource="myindex" query="SELECT * FROM t_computers"> <field column="category" template="computers" name="category"/></entity> 

Use a template to separate two objects and define the category field as a string in the schema.xml file. In addition, make sure that you pay attention to how you set the unique id parameter, some data for this particular 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 two datasets in the same index, in case you want them to work for two separate search fields, you could just do your searches, for example:

myquery AND category: (books) <--- this will bring you only the results from books, or this other will give you only the results of computers ---> myquery AND category: (computers). Hope it helps. And for your questions in pdf format, I believe that you need to use the Apache Tika module, I will not help much here, since I did not use it myself, but here is the link: http://wiki.apache.org/solr/TikaEntityProcessor

0
source share

All Articles