| <!DOCTYPE html> |
| <!--[if IE]><![endif]--> |
| <html> |
| |
| <head> |
| <meta charset="utf-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| <title>Namespace Lucene.Net.Queries |
| | Apache Lucene.NET 4.8.0-beta00013 Documentation </title> |
| <meta name="viewport" content="width=device-width"> |
| <meta name="title" content="Namespace Lucene.Net.Queries |
| | Apache Lucene.NET 4.8.0-beta00013 Documentation "> |
| <meta name="generator" content="docfx 2.56.2.0"> |
| |
| <link rel="shortcut icon" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/favicon.ico"> |
| <link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.css"> |
| <link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.css"> |
| <link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.css"> |
| <meta property="docfx:navrel" content="toc.html"> |
| <meta property="docfx:tocrel" content="queries/toc.html"> |
| |
| <meta property="docfx:rel" content="https://lucenenet.apache.org/docs/4.8.0-beta00009/"> |
| |
| </head> |
| <body data-spy="scroll" data-target="#affix" data-offset="120"> |
| <span id="forkongithub"><a href="https://github.com/apache/lucenenet" target="_blank">Fork me on GitHub</a></span> |
| <div id="wrapper"> |
| <header> |
| |
| <nav id="autocollapse" class="navbar ng-scope" role="navigation"> |
| <div class="container"> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| |
| <a class="navbar-brand" href="/"> |
| <img id="logo" class="svg" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/lucene-net-color.png" alt=""> |
| </a> |
| </div> |
| <div class="collapse navbar-collapse" id="navbar"> |
| <form class="navbar-form navbar-right" role="search" id="search"> |
| <div class="form-group"> |
| <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off"> |
| </div> |
| </form> |
| </div> |
| </div> |
| </nav> |
| |
| <div class="subnav navbar navbar-default"> |
| <div class="container hide-when-search"> |
| <ul class="level0 breadcrumb"> |
| <li> |
| <a href="https://lucenenet.apache.org/docs/4.8.0-beta00009/">API</a> |
| <span id="breadcrumb"> |
| <ul class="breadcrumb"> |
| <li></li> |
| </ul> |
| </span> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </header> |
| <div class="container body-content"> |
| |
| <div id="search-results"> |
| <div class="search-list"></div> |
| <div class="sr-items"> |
| <p><i class="glyphicon glyphicon-refresh index-loading"></i></p> |
| </div> |
| <ul id="pagination"></ul> |
| </div> |
| </div> |
| <div role="main" class="container body-content hide-when-search"> |
| |
| <div class="sidenav hide-when-search"> |
| <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a> |
| <div class="sidetoggle collapse" id="sidetoggle"> |
| <div id="sidetoc"></div> |
| </div> |
| </div> |
| <div class="article row grid-right"> |
| <div class="col-md-10"> |
| <article class="content wrap" id="_content" data-uid="Lucene.Net.Queries"> |
| |
| <h1 id="Lucene_Net_Queries" data-uid="Lucene.Net.Queries" class="text-break">Namespace Lucene.Net.Queries |
| </h1> |
| <div class="markdown level0 summary"><!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <p>Filters and Queries that add to core Lucene.</p> |
| </div> |
| <div class="markdown level0 conceptual"></div> |
| <div class="markdown level0 remarks"></div> |
| <h3 id="classes">Classes |
| </h3> |
| <h4><a class="xref" href="Lucene.Net.Queries.BooleanFilter.html">BooleanFilter</a></h4> |
| <section><p>A container <span class="xref">Lucene.Net.Search.Filter</span> that allows Boolean composition of <span class="xref">Lucene.Net.Search.Filter</span>s. |
| <span class="xref">Lucene.Net.Search.Filter</span>s are allocated into one of three logical constructs; |
| SHOULD, MUST NOT, MUST |
| The results <span class="xref">Lucene.Net.Search.Filter</span> BitSet is constructed as follows: |
| SHOULD Filters are OR'd together |
| The resulting <span class="xref">Lucene.Net.Search.Filter</span> is NOT'd with the NOT <span class="xref">Lucene.Net.Search.Filter</span>s |
| The resulting <span class="xref">Lucene.Net.Search.Filter</span> is AND'd with the MUST <span class="xref">Lucene.Net.Search.Filter</span>s</p> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.BoostingQuery.html">BoostingQuery</a></h4> |
| <section><p>The <a class="xref" href="Lucene.Net.Queries.BoostingQuery.html">BoostingQuery</a> class can be used to effectively demote results that match a given query. |
| Unlike the "NOT" clause, this still selects documents that contain undesirable terms, |
| but reduces their overall score:</p> |
| <pre><code> Query balancedQuery = new BoostingQuery(positiveQuery, negativeQuery, 0.01f);</code></pre> |
| <p>In this scenario the positiveQuery contains the mandatory, desirable criteria which is used to |
| select all matching documents, and the negativeQuery contains the undesirable elements which |
| are simply used to lessen the scores. Documents that match the negativeQuery have their score |
| multiplied by the supplied "boost" parameter, so this should be less than 1 to achieve a |
| demoting effect</p> |
| <p>This code was originally made available here: <code>[WWW] <a href="http://marc.theaimsgroup.com/?l=lucene-user&m=108058407130459&w=2">http://marc.theaimsgroup.com/?l=lucene-user&m=108058407130459&w=2</a> </code> |
| and is documented here: <code><a href="http://wiki.apache.org/lucene-java/CommunityContributions">http://wiki.apache.org/lucene-java/CommunityContributions</a></code></p> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.ChainedFilter.html">ChainedFilter</a></h4> |
| <section><p> |
| Allows multiple <span class="xref">Lucene.Net.Search.Filter</span>s to be chained. |
| Logical operations such as <strong>NOT</strong> and <strong>XOR</strong> |
| are applied between filters. One operation can be used |
| for all filters, or a specific operation can be declared |
| for each filter. |
| </p> |
| <p> |
| Order in which filters are called depends on |
| the position of the filter in the chain. It's probably |
| more efficient to place the most restrictive filters/least |
| computationally-intensive filters first. |
| </p> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.CommonTermsQuery.html">CommonTermsQuery</a></h4> |
| <section><p>A query that executes high-frequency terms in a optional sub-query to prevent |
| slow queries due to "common" terms like stopwords. This query |
| builds 2 queries off the <a class="xref" href="Lucene.Net.Queries.CommonTermsQuery.html#Lucene_Net_Queries_CommonTermsQuery_Add_Lucene_Net_Index_Term_">Add(Term)</a> added terms: low-frequency |
| terms are added to a required boolean clause and high-frequency terms are |
| added to an optional boolean clause. The optional clause is only executed if |
| the required "low-frequency" clause matches. Scores produced by this query |
| will be slightly different than plain <a class="xref" href="https://lucenenet.apache.org/docs/4.8.0-beta00013/api/core/Lucene.Net.Search.BooleanQuery.html">BooleanQuery</a> scorer mainly due to |
| differences in the <a class="xref" href="https://lucenenet.apache.org/docs/4.8.0-beta00013/api/core/Lucene.Net.Search.Similarities.Similarity.html#Lucene_Net_Search_Similarities_Similarity_Coord_System_Int32_System_Int32_">Coord(Int32, Int32)</a> number of leaf queries |
| in the required boolean clause. In most cases, high-frequency terms are |
| unlikely to significantly contribute to the document score unless at least |
| one of the low-frequency terms are matched. This query can improve |
| query execution times significantly if applicable. |
| <p> |
| <a class="xref" href="Lucene.Net.Queries.CommonTermsQuery.html">CommonTermsQuery</a> has several advantages over stopword filtering at |
| index or query time since a term can be "classified" based on the actual |
| document frequency in the index and can prevent slow queries even across |
| domains without specialized stopword files. |
| </p> |
| <p> |
| <strong>Note:</strong> if the query only contains high-frequency terms the query is |
| rewritten into a plain conjunction query ie. all high-frequency terms need to |
| match in order to match a document. |
| </p> |
| <p> |
| Collection initializer note: To create and populate a <a class="xref" href="Lucene.Net.Queries.CommonTermsQuery.html">CommonTermsQuery</a> |
| in a single statement, you can use the following example as a guide:</p> |
| <pre><code>var query = new CommonTermsQuery() { |
| new Term("field", "microsoft"), |
| new Term("field", "office") |
| };</code></pre> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.CustomScoreProvider.html">CustomScoreProvider</a></h4> |
| <section><p>An instance of this subclass should be returned by |
| <a class="xref" href="Lucene.Net.Queries.CustomScoreQuery.html#Lucene_Net_Queries_CustomScoreQuery_GetCustomScoreProvider_Lucene_Net_Index_AtomicReaderContext_">GetCustomScoreProvider(AtomicReaderContext)</a>, if you want |
| to modify the custom score calculation of a <a class="xref" href="Lucene.Net.Queries.CustomScoreQuery.html">CustomScoreQuery</a>. |
| <p>Since Lucene 2.9, queries operate on each segment of an index separately, |
| so the protected <a class="xref" href="Lucene.Net.Queries.CustomScoreProvider.html#Lucene_Net_Queries_CustomScoreProvider_m_context">m_context</a> field can be used to resolve doc IDs, |
| as the supplied <code>doc</code> ID is per-segment and without knowledge |
| of the <span class="xref">Lucene.Net.Index.IndexReader</span> you cannot access the document or <span class="xref">Lucene.Net.Search.IFieldCache</span>.</p> |
| <div class="lucene-block lucene-experimental">This is a Lucene.NET EXPERIMENTAL API, use at your own risk</div><p>@since 2.9.2</p> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.CustomScoreQuery.html">CustomScoreQuery</a></h4> |
| <section><p>Query that sets document score as a programmatic function of several (sub) scores: |
| <ul><li>the score of its subQuery (any query)</li><li>(optional) the score of its <a class="xref" href="Lucene.Net.Queries.Function.FunctionQuery.html">FunctionQuery</a> (or queries).</li></ul> |
| Subclasses can modify the computation by overriding <a class="xref" href="Lucene.Net.Queries.CustomScoreQuery.html#Lucene_Net_Queries_CustomScoreQuery_GetCustomScoreProvider_Lucene_Net_Index_AtomicReaderContext_">GetCustomScoreProvider(AtomicReaderContext)</a>. |
| <p> |
| <div class="lucene-block lucene-experimental">This is a Lucene.NET EXPERIMENTAL API, use at your own risk</div></section> |
| <h4><a class="xref" href="Lucene.Net.Queries.FilterClause.html">FilterClause</a></h4> |
| <section><p>A <span class="xref">Lucene.Net.Search.Filter</span> that wrapped with an indication of how that filter |
| is used when composed with another filter. |
| (Follows the boolean logic in <a class="xref" href="https://lucenenet.apache.org/docs/4.8.0-beta00013/api/core/Lucene.Net.Search.BooleanClause.html">BooleanClause</a> for composition |
| of queries.)</p> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.TermFilter.html">TermFilter</a></h4> |
| <section><p>A filter that includes documents that match with a specific term.</p> |
| </section> |
| <h4><a class="xref" href="Lucene.Net.Queries.TermsFilter.html">TermsFilter</a></h4> |
| <section><p>Constructs a filter for docs matching any of the terms added to this class. |
| Unlike a RangeFilter this can be used for filtering on multiple terms that are not necessarily in |
| a sequence. An example might be a collection of primary keys from a database query result or perhaps |
| a choice of "category" labels picked by the end user. As a filter, this is much faster than the |
| equivalent query (a <a class="xref" href="https://lucenenet.apache.org/docs/4.8.0-beta00013/api/core/Lucene.Net.Search.BooleanQuery.html">BooleanQuery</a> with many "should" <a class="xref" href="https://lucenenet.apache.org/docs/4.8.0-beta00013/api/core/Lucene.Net.Search.TermQuery.html">TermQuery</a>s)</p> |
| </section> |
| </article> |
| </div> |
| |
| <div class="hidden-sm col-md-2" role="complementary"> |
| <div class="sideaffix"> |
| <div class="contribution"> |
| <ul class="nav"> |
| <li> |
| <a href="https://github.com/apache/lucenenet/blob/docs/4.8.0-beta00013/src/Lucene.Net.Queries/package.md/#L2" class="contribution-link">Improve this Doc</a> |
| </li> |
| </ul> |
| </div> |
| <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix"> |
| <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> --> |
| </nav> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| <footer> |
| <div class="grad-bottom"></div> |
| <div class="footer"> |
| <div class="container"> |
| <span class="pull-right"> |
| <a href="#top">Back to top</a> |
| </span> |
| Copyright © 2020 The Apache Software Foundation, Licensed under the <a href='http://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache License, Version 2.0</a><br> <small>Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation. <br>All other marks mentioned may be trademarks or registered trademarks of their respective owners.</small> |
| |
| </div> |
| </div> |
| </footer> |
| </div> |
| |
| <script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.js"></script> |
| <script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.js"></script> |
| <script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.js"></script> |
| </body> |
| </html> |