0

我正在创建一个搜索,用户可以在其中选择一个间隔并同时搜索一个术语。

然而,这给我带来了麻烦,因为我到目前为止只使用了通常的文本查询。

我想知道如何同时使用 NumericRangeQuery 和常规术语查询。通常我会使用下面的查询:

var parser = new MultiFieldQueryParser(
         new[] { "FromPrice", "ToPrice", "Description"}, new SimpleAnalyzer());
        Query query = parser.Parse(searchQuery.ToString());
        IFullTextSession session = Search.CreateFullTextSession(this.Session);
        IQuery fullTextQuery = session.CreateFullTextQuery(query, new[] { typeof(MyObject) });
        IList<MyObject> results = fullTextQuery.List<MyObject>();

但是,如果我要搜索范围 FromPrice <-> ToPrice 以及描述,我应该怎么做,因为 session.CreateFullTextQuery 只需要一个 Query 对象?

4

1 回答 1

0

您可以创建一个单一的查询,它是一个结合您想要满足的所有条件的 BooleanQuery。

对于范围,这里是使用 QueryParser 的合成器的链接:http://lucene.apache.org/core/old_versioned_docs/versions/2_9_2/queryparsersyntax.html#Range Searches

于 2011-09-07T18:47:34.850 回答