2
votes

I have gone through the lucene indexing mechanism. I have some doubts for which i couldn't find a straight answer and i am still confused with my reading in several references.

Consider indexing a database table using lucene.

suppose the table has 10 columns few being caseid, modifiedby, modifiedtime, casename, legalname and so on...

now if i create an index on case id then while searching is it possible to search based on modified by field???

suppose i create an index on 2 columns caseid and modifiedby then how will the indexing be done and the doubt similar to previous one can we search based on legal name which is not indexed??

2

2 Answers

1
votes

If I get your intent right (I work in Search domain where its not just about bag of words, its about the intent too :)), here you go:

SOLUTION 1

Step 1: Create a field, for example call it Data (dont forget to mark it multivalued) in your schema.xml, something like:

<field name="Data" type="text" indexed="true" stored="true" required="false" multiValued="true" />

Step 2: You can copy the contents of the all the fields you want to be searched to Data (created above) using a copyfield directive in your schema.xml something like

<copyField source="caseId" dest="Data" />
<copyField source="modifiedBy" dest="Data" />
<copyField source="casename" dest="Data" />

Step 3: Mark the default search field () to be Data in schema.xml

Now when you issue a query it will search for all the fields you have copied to Data.

SOLUTION 2

There is an alternate solution wherein in the query itself you can specify the fieldname something like q=Hello+casename:Hello (In this particular case it would search for hello in the field marked as default and also search for Hello in casename). You can have multiple search declarations in your query. But I suggest my previous approach.

0
votes

now if i create an index on case id then while searching is it possible to search based on modified by field???

Set "indexed=true" to all the fields you need to be indexed. I don't understand why do you afraid to index all the colums you need.

Don't you confused with MySQL indexes?