Question

I got indexed some data of a MySQL db in my Solr engine. It works fine when I search keywords along with the field names : "q=texted_value:car" returns my db record

<doc><str name="id">6</str><str name="texted_value">car</str></doc>

However, I need to be able to perform full-text search in my db, without giving the fieldname (q=car). So how do we do that ? If it's including Transformer or Processor in my data-config will you please guide me ?

my data-config.xml :

<entity name="test0" 
pk="id"
query="select * from test0">
<field column="value_t" name="texted_value" />
</entity>

Thx

Was it helpful?

Solution

Common technique used to search across fields in Solr is to use copyField directive. This copies values from the original field to destination field. Normally it is indexed without norms & not stored.

<copyField source="columnA" dest="textAll" maxChars="20" />
<copyField source="columnB" dest="textAll" maxChars="20" />
<copyField source="columnC" dest="textAll" maxChars="20" />
....

Make textAll field as default field in your schema.xml,

<defaultSearchField>textAll</defaultSearchField>

Now you can search http://server/solr/select/?q=car this will search across all your fields. This will increase the performance of your searching, instead of searching each fields individually you search for one field textAll. It comes with a price of increase in indexing time & file size.

Read Solr copyFields

OTHER TIPS

You can specify the searchable columns with the DisMax Query Parser. copyField will also work but requires schema changes. Both are good options depending on the situation.

**?q=car&qf=column1 column2&defType=dismax

    //search for the word "car"
    ?q=car

    //specify all the columns to search in
    &qf=column1 column2

    //use dismax
    &defType=dismax
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top