2015-08-18 23 views
0

我在Solr的初學者,我發現查詢如何Solr的查詢,而無需鑰匙

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

正常工作與它與Solr的包我想我自己創造一個走過來的默認集合新的收集和查詢它我的查詢是:

http://localhost:8983/solr/newcollection/select?q=book1&wt=json&indent=true不工作?

因此如何使這個查詢工作,我的模式是

<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> 
+0

什麼是你的索引的內容?你期望什麼結果? – MatsLindh

+0

獲取ID爲book1的文檔@MatsLindh –

+1

是否有ID爲book1的文檔? 「id:book1」是否有效? (如果沒有字段,Solr將搜索默認字段或「qf/df」參數中提供的字段) – MatsLindh

回答

0

我們必須定義默認搜索字段SOLR,以便查詢中不包含指定任何領域一起工作。

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> 
+0

可以將任何字段設置爲默認值。 @AneeshMonN –

+1

我不確定在默認允許的最大字段中,我們保留一個字段並將必要字段的值複製到該字段。如有必要,您甚至可以在某些領域實現提升 –