在Lucene中搜索短语(Searching phrases in Lucene)
有人能指出我如何用Lucene.net搜索短语的例子吗?
假设我在索引中有一个带有字段“name”的文档,值为“Jon Skeet”。 现在我希望能够在搜索“jon skeet”时找到该文档。
Could somebody point me to an example how to search for phrases with Lucene.net?
Let's say I have in my index a document with field "name", value "Jon Skeet". Now I want to be able to find that document when searching for "jon skeet".
原文:https://stackoverflow.com/questions/343002
更新时间:2021-11-25 16:11
最满意答案
您需要在if语句中检查SqlDataReader.IsDBNull(0),如下所示:
if (rd43.IsDBNull(0)) { Products.Add("0"); } else { Products.Add(rd43.GetString(0)); }
您可以在此处找到有关它的更多信息
You need to check SqlDataReader.IsDBNull(0) in your if statement like below:
if (rd43.IsDBNull(0)) { Products.Add("0"); } else { Products.Add(rd43.GetString(0)); }
More information about it you can find here
相关问答
更多-
这不完美但是你走了。 你已经完成了部分工作: using(SqlConnection con = new SqlConnection(conString)) { con.Open(); var query=@"Select forename, surname, caseid, postcode, telephone, email FROM TestDB.crm-data WHERE caseid=@caseId OR email=@email"; ...
-
SQL查询在SQL Server 2008中有效,但在C#中不起作用(SQL query works in SQL Server 2008 but doesn't work in C#)[2023-10-11]
请将CommandText放入CommandType并尝试。 using(SqlConnection sqcon = new SqlConnection( "Data Source=WMLON-Z8-SQL20,61433;Initial Catalog=statusdb;Integrated Security=True")) { using(SqlCommand command = new SqlCommand(squery,sqcon)){ command.CommandType = ... -
当我将它放入C#方法时,为什么这个SQL Server查询无法工作?(Why this SQL Server query can't work when I put it into a C# method?)[2021-12-04]
你的查询应该是这样的 _strSQL = "SELECT * FROM VulnerabilityReference" + " WHERE Title = @REFERENCETITLE and convert(nvarchar(MAX), Description2) = @DESCRIPTION2 "; your query should look like _strSQL = "SELECT * FROM VulnerabilityReference" ... -
警告 :我实际上不会这样做,但这是试图回答这个问题。 我的官方立场是在底部。 如果我正确地阅读你的问题,你的努力实际上是“解析”文本文件以获得所需的查询。 如果是这种情况,我强烈建议不要使用直接text来完成此任务。 您需要某种结构,以便程序知道如何获取适当的信息。 标记语言基本上是结构化的文本,允许程序导航文档。 有很多标记可以工作,以下是一些可以满足您需求的标记。 如果你想把它保存在一个.txt文件中,并保持它很简单,你可以尝试使用像toml这样的东西 ,并用toml.net 或类似的东西解析它 更优选 ...
-
第一个问题: 如果要显示查询中的多个列,可以使用gridview作为查询。 第二个问题: 并且您可以使用DataSet获取多个表,以防万一需要。 检查这个: string queryCustomer = "SELECT CustomerID, CompanyName FROM dbo.Customers"; SqlDataAdapter adapter = new SqlDataAdapter(queryCustomer , connection); DataSet dataSet = new Data ...
-
你有几个选择: 您可以在插入数据库之前读取XML节点,并插入规范化的表列值。 通过将XML字符串作为输入参数传递,可以在存储过程中粉碎XML。 您可以在此处阅读有关如何使用nodes()方法粉碎XML的信息 。 You have a few options: You can read the XML nodes before inserting into the database, and insert normalized table column values. You can shred the XM ...
-
来自C#的SQL查询(SQL query from C#)[2021-07-21]
尝试在where子句中围绕值添加引号,如下所示: select * from table where NAME = 'name' and LAST_NAME = 'last_name' 在你使用变量的情况下,你需要添加引号,然后将变量的值连接到字符串中。 或者你可以像这样使用String.Format : var sql = String.Format("select * from table where [NAME] = '{0}' and LAST_NAME = '{1}'", name, last_ ... -
您可以使用DataTable.WriteXML()和DataTable.WriteXmlSchema()方法为查询生成XML。 SqlCommand cmd = new SqlCommand("Your Command", new SqlConnection("Connection String")); DataTable dt = new DataTable(); new SqlDataAdapter(cmd).Fill(dt); dt.TableName = "Your Table Name"; dt ...
-
从数据库中读取数据,然后在C#中的某些条件下过滤数据(Reading data from Database and then filter data on some condition in C#)[2021-12-29]
正如@Steve在他的评论中提到的,一个好的做法是在SQL查询中尽可能多地过滤。 有多种方法可以使用T-sql条件( WHERE , GROUP BY , HAVING等)过滤和操作数据。 与您在应用程序中可以执行的操作相比,SQL Server非常有效。 这里有一个关于这个主题的有趣讨论: “永远不要在代码中做什么,你可以让SQL服务器为你做好” - 这是一个糟糕设计的秘诀吗? 另一方面,有一些例外情况,使用sql steatments将丢失资源而且不必要。 例如高频GUI更改和更新,遇到类似这样的情况时 ... -
如何在C#中读取SQL Server查询数据时放入IF条件(How to put IF condition while reading SQL Server query data in C#)[2023-04-20]
您需要在if语句中检查SqlDataReader.IsDBNull(0),如下所示: if (rd43.IsDBNull(0)) { Products.Add("0"); } else { Products.Add(rd43.GetString(0)); } 您可以在此处找到有关它的更多信息 You need to check SqlDataReader.IsDB ...