2012-01-27 120 views
0

我在我的Solr引擎中索引了MySQL數據庫的一些數據。當我搜索關鍵字字段名沿着它工作正常:「Q = texted_value:汽車」返回我的數據庫記錄搜索Solr上的DIH索引數據

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

不過,我需要能夠在我的數據庫進行全文搜索,不給字段名稱(q = car)。那麼我們該怎麼做?如果它包括我的數據配置中的變壓器或處理器,請引導我嗎?

我的數據-config.xml中:

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

THX

+0

嗯,你心裏有什麼樣的(領域和)查詢?請給我們幾個例子。你是說你需要在單個查詢中搜索多個字段? – aitchnyu 2012-01-27 18:31:20

回答

2

使用跨在Solr的字段進行搜索常用的技術是使用copyField指令。這會將原始字段的值複製到目標字段。通常它沒有存儲規範&索引。

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

讓你schema.xmltextAll字段默認字段,

<defaultSearchField>textAll</defaultSearchField> 

現在您可以搜索的http://服務器/ Solr的/選擇/ Q =車這會同時搜索所有領域。這將提高搜索的性能,而不是單獨搜索每個字段,而是搜索一個字段textAll。它帶有索引時間的增加價格&文件大小。

閱讀Solr copyFields

+0

thx,它工作的很棒! – zg2pro 2012-01-30 12:27:31

0

您可以用DisMax Query Parser指定檢索列。 copyField也將工作,但需要架構更改。根據情況,兩種都是很好的選擇。

** Q =汽車& QF =列1列2 & DEFTYPE = dismax

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

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

    //use dismax 
    &defType=dismax