My database has three columns, which I configured lucene to index. However, I can search by only one of them. Complete description is the following:
I am following these instructions to configure solr to use mysql data:
http://digitalpbk.com/apachesolr/apache-solr-mysql-sample-data-config
I downloaded the jdbc driver, put it in /example/lib, and created a new requestHandler in /example/conf/solrconfig.xml.
My database table items has three columns:
-
id: int, primary, autoincrement key -
name: varchar(256) -
description: varchar(511)
So, I create following data-config.xml:
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://SERVER/DATABASE"
user="USERNAME"
password="PASSWORD"/>
<document name="content">
<entity name="node" query="select id, name, description from items">
<field column="id" name="id" />
<field column="name" name="name" />
<field column="description" name="description" />
</entity>
</document>
</dataConfig>
Next, I edit schema.xml in /example/solr/conf to let it know about new names:
<field name="id" type="string" indexed="true" stored="true">
<field name="name" type="string" indexed="true" stored="true">
<field name="description" type="string" indexed="true" stored="true">
I had to uncomment the descriptions of id and name which were present in this file earlier, since they clashed with my descriptions.
Next, I imported the database (around 100K rows) successfully.
At the end of all this, I can successfully search by name, but I am unable to search by description or by id. I do not understand why this should be the case. Any help or pointers would be appreciated.
Name field may be the default field name to search. So make sure you are referring the field names in your query.
To search in
descriptionfield use query:description:queryStringTo search in all fields use query:
id:queryString OR name:queryString OR description:queryStringFor more information please check http://wiki.apache.org/solr/SolrRelevancyFAQ