English 中文(简体)
Solr 3.3.0 - 增加实地搜索量——加强外地优先事项
原标题:Solr 3.3.0 - Increase field weight in search - boost field priority

I m Indexing with solr 3.3.0 these docs:

<book id="bk101">
        <keywords>----</keywords>
        <title>----</title>
        <owner>----</owner>
        <artist>abcde</artist>
    </book>
    <book id="bk102">
        <keywords>----</keywords>
        <title>----</title>
        <owner>abcde</owner>
        <artist>----</artist>
    </book>
    <book id="bk103">
        <keywords>----</keywords>
        <title>----</title>
        <owner>----</owner>
        <artist>abc</artist>
    </book>
    <book id="bk104">
        <keywords>----</keywords>
        <title>----</title>
        <owner>abc</owner>
        <artist>----</artist>
    </book>
    <book id="bk105">
        <keywords>abcde</keywords>
        <title>----</title>
        <owner>----</owner>
        <artist>----</artist>
    </book>
    <book id="bk106">
        <keywords>abc</keywords>
        <title>----</title>
        <owner>----</owner>
        <artist>----</artist>
    </book>
    <book id="bk107">
        <keywords>----</keywords>
        <title>abcde</title>
        <owner>----</owner>
        <artist>----</artist>
    </book>
    <book id="bk108">
        <keywords>----</keywords>
        <title>abc</title>
        <owner>----</owner>
        <artist>----</artist>
    </book>

Schema.xml

<types>
    <fieldType name="text" class="solr.TextField" positionIncrementGap="100" omitNorms="false">
        <tokenizer class="solr.WhitespaceTokenizerFactory" />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0" splitOnNumerics="0" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true" />
        <filter class="solr.ISOLatin1AccentFilterFactory" />
        <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="15" side="front" />
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="15" side="back" />
    </fieldType>

    <fieldType name="text_original" class="solr.TextField" positionIncrementGap="100" omitNorms="false">
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
    </fieldType>

    <fieldType name="uuid" class="solr.UUIDField" indexed="true" />
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" />
    <fieldType name="float" class="solr.FloatField" omitNorms="true" />
    <fieldType name="date" class="solr.DateField" />
</types>

<fields>
    <field name="id" type="uuid" indexed="true" stored="true" default="NEW" />
    <field name="book_id" type="string" indexed="true" stored="true" />
    <field name="keywords" type="text" indexed="true" stored="true" />
    <field name="keywords_ex" type="text_original" indexed="true" stored="true" />
    <field name="title" type="text" indexed="true" stored="true" />
    <field name="title_ex" type="text_original" indexed="true" stored="true" />
    <field name="owner" type="text" indexed="true" stored="true" />
    <field name="owner_ex" type="text_original" indexed="true" stored="true" />
    <field name="artist" type="text" indexed="true" stored="true" />
    <field name="artist_ex" type="text_original" indexed="true" stored="true" />

    <copyField source="title" dest="title_ex" />
    <copyField source="keywords" dest="keywords_ex" />
    <copyField source="owner" dest="owner_ex" />
    <copyField source="artist" dest="artist_ex" />

</fields>

你们可以看到,我是否在寻找一个排气器时回收所有的docs(Im使用固体)。 Edge a. 指数化工厂;我的成就是利用这一逻辑整理出文件:

  1. title_ex
  2. title
  3. keywords_ex
  4. keywords
  5. owner_ex
  6. artist_ex
  7. owner
  8. artist

我尝试了“^”的 l子和 dis子,但答复清单是我所说的。

http:// localhost:8080/solr33a/core0/select?q=abc&defType=edismax&qf=title_ex^10%20 entitled^8.0%20keywords_ex^6%20keywords^20 Owner_ex^1.2%20artist_ex^0.820 Owner^ 20art^0.2&fl=

结果:

<doc>
            <float name="score">2.3862944</float>
            <str name="artist">----</str>
            <str name="artist_ex">----</str>
            <str name="book_id">bk108</str>
            <str name="id">2cc5d478-6901-4777-abc9-680fd959ef90</str>
            <str name="keywords">----</str>
            <str name="keywords_ex">----</str>
            <str name="owner">----</str>
            <str name="owner_ex">----</str>
            <str name="title">abc</str>
            <str name="title_ex">abc</str>
        </doc>
        <doc>
            <float name="score">1.4317766</float>
            <str name="artist">----</str>
            <str name="artist_ex">----</str>
            <str name="book_id">bk106</str>
            <str name="id">e12683a2-faff-4d86-8107-7406491f4f89</str>
            <str name="keywords">abc</str>
            <str name="keywords_ex">abc</str>
            <str name="owner">----</str>
            <str name="owner_ex">----</str>
            <str name="title">----</str>
            <str name="title_ex">----</str>
        </doc>
        <doc>
            <float name="score">0.3288517</float>
            <str name="artist">----</str>
            <str name="artist_ex">----</str>
            <str name="book_id">bk107</str>
            <str name="id">a6a4a014-ce94-4257-a215-c1a64aa41cf5</str>
            <str name="keywords">----</str>
            <str name="keywords_ex">----</str>
            <str name="owner">----</str>
            <str name="owner_ex">----</str>
            <str name="title">abcde</str>
            <str name="title_ex">abcde</str>
        </doc>
        <doc>
            <float name="score">0.28635535</float>
            <str name="artist">----</str>
            <str name="artist_ex">----</str>
            <str name="book_id">bk104</str>
            <str name="id">9b909c65-e56a-4407-a789-53a570a7ae40</str>
            <str name="keywords">----</str>
            <str name="keywords_ex">----</str>
            <str name="owner">abc</str>
            <str name="owner_ex">abc</str>
            <str name="title">----</str>
            <str name="title_ex">----</str>
        </doc>
        <doc>
            <float name="score">0.22608554</float>
            <str name="artist">----</str>
            <str name="artist_ex">----</str>
            <str name="book_id">bk105</str>
            <str name="id">dead87cc-f93b-4562-af32-4d9fb2613c7f</str>
            <str name="keywords">abcde</str>
            <str name="keywords_ex">abcde</str>
            <str name="owner">----</str>
            <str name="owner_ex">----</str>
            <str name="title">----</str>
            <str name="title_ex">----</str>
        </doc>
        <doc>
            <float name="score">0.19090356</float>
            <str name="artist">abc</str>
            <str name="artist_ex">abc</str>
            <str name="book_id">bk103</str>
            <str name="id">306a252c-a0b5-474d-b55d-a25740d063b4</str>
            <str name="keywords">----</str>
            <str name="keywords_ex">----</str>
            <str name="owner">----</str>
            <str name="owner_ex">----</str>
            <str name="title">----</str>
            <str name="title_ex">----</str>
        </doc>
        <doc>
            <float name="score">0.020553231</float>
            <str name="artist">----</str>
            <str name="artist_ex">----</str>
            <str name="book_id">bk102</str>
            <str name="id">a684de0c-b286-4d9e-bd68-d5305afeee76</str>
            <str name="keywords">----</str>
            <str name="keywords_ex">----</str>
            <str name="owner">abcde</str>
            <str name="owner_ex">abcde</str>
            <str name="title">----</str>
            <str name="title_ex">----</str>
        </doc>
        <doc>
            <float name="score">0.008221293</float>
            <str name="artist">abcde</str>
            <str name="artist_ex">abcde</str>
            <str name="book_id">bk101</str>
            <str name="id">30a0f9de-1224-49d2-90aa-41f57af4956c</str>
            <str name="keywords">----</str>
            <str name="keywords_ex">----</str>
            <str name="owner">----</str>
            <str name="owner_ex">----</str>
            <str name="title">----</str>
            <str name="title_ex">----</str>
        </doc>
问题回答

As you want to search across multiple fields with variable weightage, configure your request handler to use edismax query parser.
dismax allows you to search across fields and add weights to each field.

Example title match has weight 1, while matches on author 0.8, so that document having title matches would appear at the top.

<requestHandler name="search" class="solr.SearchHandler" default="true">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <str name="defType">edismax</str>
   <str name="qf">
      title^1 author^0.8
   </str>
   <str name="q.alt">*:*</str>
   <str name="rows">10</str>
   <str name="fl">*,score</str>
 </lst>
</requestHandler>




相关问题
solr problem to get the field names

Ive got a problem. In each document I ve got fields: threads.id and posts.id. I want to get the field name value for them so i can get data from the database. Between the lines beneath i have marked ...

Which is the better client for Solr + PHP?

I have two options http://www.php.net/manual/en/book.solr.php http://code.google.com/p/solr-php-client/ I read it somewhere that that 2) use JSON as output types whereas 1) use XML doc. Isn t ...

Geronimo vs Glassfish

For a production environment, is Apache Geronimo better for applications that uses ActiveMQ, Derby, Solr?

Sort by date in Solr/Lucene performance problems

We have set up an Solr index containing 36 million documents (~1K-2K each) and we try to query a maximum of 100 documents matching a single simple keyword. This works pretty fast as we had hoped for. ...

SOLR - delta import not with last_modified

I saw only ways using delta import with last_modified. Is there some other ways to do delta_imports withut using timestamps? For example, if i have unique key(integer), can i tell SOLR to index only ...

SOLR How to return only limited matched content

ok guys, say in my Schema I have 4 fields: <field name="SiteIdentifier" type="string" indexed="true" stored="true" required="true"/> <field name="Title" type="text" indexed="true" stored="...

Solr - character substitution

I have Solr with indexed database. In my database all data is in Latvian. The problem is, I need to be able to search word Riga as if it is word Rīga. Of course, i can define synonym - Rīga = Riga, ...

热门标签