2012-01-27 129 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