2013-05-06 42 views
0

我是日光浴新手,我使用的是版本2.我已经创建了架构,并且我需要知道如何传递搜索关键字,该关键字应该在所有字段中搜索或少量字段按照xml。搜索键,在xml中提到的所有字段

例如:我的领域是这样的。 "title", "description", "keywords" etc.所以当用户输入一些单词作为"xyz"它应该搜索所有上面提到的领域,并产生输出。它应该搜索不仅有确切的,但应该是像我们这样的sql "like"

日光浴的样本例子并没有得到方便。

任何帮助表示赞赏。

编辑_领域中

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer type="index"> 
    <tokenizer class="solr.StandardTokenizerFactory"/> 
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" /> 
    <!-- in this example, we will only use synonyms at query time 
    <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> 
    --> 
    <filter class="solr.LowerCaseFilterFactory"/> 

我所有的字段类型是text_general ..我用的Solr 4.2.1

+0

和我的solr版本是4.2.1 – sandy 2013-05-06 09:43:26

回答

1

你可以配置你的schema.xml到

  1. 使用copyfield到将标题,说明,关键字组合到单个字段中,然后在该字段上进行搜索。
  2. 使用EdgeNGramFilter过滤器将作品分解为碎片以匹配类似于sql的行为。

例如

<fieldType name="text" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer> 
     <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
     <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="25" /> 
     <filter class="solr.LowerCaseFilterFactory"/> 
    </analyzer> 
</fieldType> 


<field name="all_fields" type="text" indexed="true" stored="false" multiValued="true"/> 

<copyField source="title" dest="all_fields"/> 
............... 
+0

谢谢你的回答jayendra。我将点编号1添加为并且关于点2,我是否必须添加 .....没有任何更改,如链接中所述EdgeNGramFilterFactory ??? ? – sandy 2013-05-06 12:27:40

+0

更新了答案。你可以进一步调整它。 – Jayendra 2013-05-06 12:37:56

+0

嘿,我这么做...抱歉打扰你更多...我如何在客户端实现?即如何从客户端传递?我为客户端使用日光浴室!是否有任何文件,你可以引用我也或任何其他替代 – sandy 2013-05-06 12:49:50