0

I am a beginner in solr i found that the query

http://localhost:8983/solr/collection1/select?q=book%0A&wt=json&indent=true

works fine with the default collection which came along with the solr package i tried my self to create a new collection and query it my query is:

http://localhost:8983/solr/newcollection/select?q=book1&wt=json&indent=true is not working?

so how to make this query work my schema is

    <fieldType name="string" class="solr.StrField"  />
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" >
    </fieldType>

    <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
    <fieldtype name="binary" class="solr.BinaryField"/>

    </types>

    <fields><field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="title" type="text_general" indexed="true" stored="true" multiValued="false"/>
   <field name="genere" type="text_general" indexed="true" stored="true"/>
   <field name="description" type="text_general" indexed="true" stored="true" multiValued="false"/>
   <field name="comments" type="text_general" indexed="true" stored="true" multiValued="true"/>
   <field name="author" type="text_general" indexed="true" stored="true" />
   <field name="publications" type="text_general" indexed="true" stored="true" multiValued="true" />

    </fields>
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
Aswin Raghavan
  • 321
  • 2
  • 14

2 Answers2

0

We will have to define default search fields to SOLR so as to work with without specifying any fields in the query.

Define as below in solrconfig.xml

<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="defaults">
         <str name="echoParams">explicit</str>
         <int name="rows">10</int>
         <str name="df">description comments </str>
    </lst>
</requestHandler>
Aneesh Mon N
  • 696
  • 3
  • 9
  • can any no of fields be made defaults. @AneeshMonN – Aswin Raghavan Aug 19 '15 at 03:53
  • 1
    I am not sure on maximum fields allowed in the defaults, we keep one field and copy value from necessary fields to that. You can even achieve boosting here for certain fields if necessary – Aneesh Mon N Aug 19 '15 at 04:02
0

Another option is to use edismax and specify which fields you want to use. For example you could issue a query like:

http://localhost:8983/solr/newcollection/select?q=book1&wt=json&indent=true&qf=description comments&deftype=edismax

xmorera
  • 1,933
  • 3
  • 20
  • 35