You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Romita Saha <Ro...@sg.panasonic.com> on 2012/10/23 05:09:48 UTC

searching a database element

Hi,

I have indexed from a database. I have specified a field type laptop. In 
the database, laptop has the value equal to Dell. I can search laptop: 
Dell from the database with the following command.

http://localhost:8983/solr/db/select/?q=laptop:Dell&start=0&rows=4&fl=laptop

Can i search for just the query string dell without specifying that it is 
of field type laptop?

Below is my data-config and schema.xml file:

data-config.xml:

<dataConfig>
    <dataSource driver="com.mysql.jdbc.Driver" 
url="jdbc:mysql://localhost/camerasys" user="root"
      password= "123" />
    <document>
        <entity name="computer" 
                query="SELECT * FROM computer">
                <field column="laptop" name="laptop"/>
 


        </entity>
    </document>
</dataConfig>

schema.xml:
    <field name="laptop" type="string" indexed="true" stored="true" 
required="true"/>
   <uniqueKey>laptop</uniqueKey>

Romita Saha


Re: searching a database element

Posted by Romita Saha <Ro...@sg.panasonic.com>.
Hi,

It worked. I was specifying more than one filed under defaultSearchField. 
Once I specified just the required field, it is able to do the search. 
Thanks a lot for your guidance.

Romita 




From:   "Romita Saha" <Ro...@sg.panasonic.com>
To:     solr-user@lucene.apache.org, 
Date:   10/23/2012 12:31 PM
Subject:        Re: searching a database element



Hi,

Sorry for the typo in the previous mail.  I am searching for dell 
actually. The query is 
http://.../solr/db/select?q=dell&start=0&rows=4&fl=laptop 

I am not applying any analyzer/tokenizer for the fieldType 'string'. I 
also want to share my solrconfig file with you.

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

Thanks and regards,
Romita Saha




From:   adityab <ad...@yahoo.com>
To:     solr-user@lucene.apache.org, 
Date:   10/23/2012 12:19 PM
Subject:        Re: searching a database element



Are you applying any analyzer/tokenizer for the fieldType 'string' (i 
guess
no)
your query in the response shows '*dell*' where as you are store data is
'*Dell*'. 

If you wan to search ignoring the case then you might need to use
LowerCaseFilterFactory as analyzer to the field. and then perform the
search. 




--
View this message in context: 
http://lucene.472066.n3.nabble.com/searching-a-database-element-tp4015293p4015298.html


Sent from the Solr - User mailing list archive at Nabble.com.



Re: searching a database element

Posted by Romita Saha <Ro...@sg.panasonic.com>.
Hi,

Sorry for the typo in the previous mail.  I am searching for dell 
actually. The query is 
http://.../solr/db/select?q=dell&start=0&rows=4&fl=laptop 

I am not applying any analyzer/tokenizer for the fieldType 'string'. I 
also want to share my solrconfig file with you.

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

Thanks and regards,
Romita Saha




From:   adityab <ad...@yahoo.com>
To:     solr-user@lucene.apache.org, 
Date:   10/23/2012 12:19 PM
Subject:        Re: searching a database element



Are you applying any analyzer/tokenizer for the fieldType 'string' (i 
guess
no)
your query in the response shows '*dell*' where as you are store data is
'*Dell*'. 

If you wan to search ignoring the case then you might need to use
LowerCaseFilterFactory as analyzer to the field. and then perform the
search. 




--
View this message in context: 
http://lucene.472066.n3.nabble.com/searching-a-database-element-tp4015293p4015298.html

Sent from the Solr - User mailing list archive at Nabble.com.


Re: searching a database element

Posted by adityab <ad...@yahoo.com>.
Are you applying any analyzer/tokenizer for the fieldType 'string' (i guess
no)
your query in the response shows '*dell*' where as you are store data is
'*Dell*'. 

If you wan to search ignoring the case then you might need to use
LowerCaseFilterFactory as analyzer to the field. and then perform the
search. 




--
View this message in context: http://lucene.472066.n3.nabble.com/searching-a-database-element-tp4015293p4015298.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: searching a database element

Posted by Romita Saha <Ro...@sg.panasonic.com>.
Hi,

I added <defaultSearchField>laptop</defaultSearchField> to the schema.xml 
file. However the query 
http://.../solr/db/select?q=Dell&start=0&rows=4&fl=laptop is not able to 
search for dell. Following is the response.

<response>
  <lst name="responseHeader">
        <int name="status">0</int>
        <int name="QTime">2</int>
        <lst name="params"><str name="indent">on</str>
        <str name="start">0</str><str name="q">dell</str>
        <str name="version">2.2</str>
        <str name="rows">10</str>
  </lst>
</lst>
<result name="response" numFound="0" start="0"/></response>

Thanks and regards,
Romita Saha





From:   adityab <ad...@yahoo.com>
To:     solr-user@lucene.apache.org, 
Date:   10/23/2012 12:01 PM
Subject:        Re: searching a database element



if i understand correctly you are looking for the below attribute in
schema.xml to be defined.

<defaultSearchField>laptop</defaultSearchField>

you query can now be 
http://.../solr/db/select?q=Dell&start=0&rows=4&fl=laptop





--
View this message in context: 
http://lucene.472066.n3.nabble.com/searching-a-database-element-tp4015293p4015296.html

Sent from the Solr - User mailing list archive at Nabble.com.


Re: searching a database element

Posted by adityab <ad...@yahoo.com>.
if i understand correctly you are looking for the below attribute in
schema.xml to be defined.

<defaultSearchField>laptop</defaultSearchField>

you query can now be 
http://.../solr/db/select?q=Dell&start=0&rows=4&fl=laptop





--
View this message in context: http://lucene.472066.n3.nabble.com/searching-a-database-element-tp4015293p4015296.html
Sent from the Solr - User mailing list archive at Nabble.com.