如何在nhibernate.search查询中使字段名称不敏感

时间:2021-01-09 03:08:31

I would like to make the field name in my query case incesitive so that when users make the queries

我想在我的查询案例中使字段名称具有强制性,以便在用户进行查询时

title:Jurassic

or

Title:Jurassic

NHibernate Search would yield the same result.

NHibernate Search会产生相同的结果。

As I understand the way Lucene works field names are case sensitive. Is there a way to configure NH Search/Lucene to lowercase the field names when indexing and lowercase the fieldname when searching?

据我所知,Lucene的工作方式字段名称区分大小写。有没有办法在索引时将NH Search / Lucene配置为小写字段名称,并在搜索时将字段名小写?

1 个解决方案

#1


Field names are case sensitive. One way is to specify all of your fields to be completely lowercase and then lowercase your query.

字段名称区分大小写。一种方法是将所有字段指定为完全小写,然后将查询小写。

class example:

[Indexed]
class Article
{
     [Field(Name="title", Index=Index.Tokenized, Store=Store.No)]
     Title { get; set; }
}

query example

string query = tbSearch.Text;
query = query.ToLower();
IFullTextQuery ftq = search.CreateFullTextQuery(query);

#1


Field names are case sensitive. One way is to specify all of your fields to be completely lowercase and then lowercase your query.

字段名称区分大小写。一种方法是将所有字段指定为完全小写,然后将查询小写。

class example:

[Indexed]
class Article
{
     [Field(Name="title", Index=Index.Tokenized, Store=Store.No)]
     Title { get; set; }
}

query example

string query = tbSearch.Text;
query = query.ToLower();
IFullTextQuery ftq = search.CreateFullTextQuery(query);