0
votes

I have 4 rows in MySQL and I'm indexing them into Solr from admin console. The import executes successfully and I get this message "Indexing completed. Added/Updated: 4 documents. Deleted 0 documents. (Duration: 01s)".

Next, when I try to query some text from one of the rows, I do not get any result. I haven't changed any of the parameters for querying. This is entry in the log file:

org.apache.solr.core.SolrCore; [collection1] webapp=/solr path=/select params={indent=true&q=LG&_=1397953906088&wt=json} hits=0 status=0 QTime=1

I've updated the config files as blow:

solrconfig.xml:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
      <str name="config">data-config.xml</str>
    </lst>
</requestHandler>

dataconfig.xml:

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/test" 
              user="root" 
              password=""/>
  <document>
    <entity name="id" 
            query="select id,name,descpt from sample">
    </entity>
  </document>
</dataConfig>

In schema.xml, I've added the corresponding fields:

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> 
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="descpt" type="string" indexed="true" stored="true"/>

The corresponding entry in database for id, name, and descpt:

4, Television, LG

Why don't I get any results when I query for LG? I'm new to Solr, so I might be missing something here.

Thanks.

1
Realized that I need to query for "descpt:LG". But now, I have another question. I have another entry as "3, Phone, iPhone" for the columns id, name, descpt. Now, when I search for descpt:phone, I don't see the entry for iPhone. How can I search for partial matches? - drunkenfist
Because there is a difference b/w 'P' and 'p'. Since you are using descpt as string field, it will match the exact expressions. so if you search for descpt:Phone it will work. - javacreed

1 Answers

0
votes

If you are doing a common search on all the elements indexed. You should use copyField to index them to a single field and then retireve it.

There is something like a copy Fields in solr. Copy fields can copy your indexes to a common field. So then if you query on that field all the data will be searched.

You should define copy fields as

<copyField source="id" dest="text"/>
<copyField source="name" dest="text"/>

Here dest stands for the destination field... check what is the default query field for your solr distribution and use it in the destination.

Please check your defaultsearchfield tag in schema.xml it should be

text

for this particular case.

Then you can search it without specifying a particular field.

Regarding your second doubt

There is a difference b/w 'P' and 'p'. Since you are using descpt as string field, it will match the exact expressions. so if you search for descpt:Phone it will work