本文介绍了在Azure搜索中(一个以上)提出多个建议或两个建议之间的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过FirstName,LastName和Email在下拉列表中建议一个用户列表。我已经在azure控制台中创建了一个索引来标记带有建议者的字段,如下所示:

I need to suggest a list of users in a dropdown by FirstName, LastName, and Email I have created an index marking the fields with the suggester in the azure console as follows:

这仅适用于FirstName查询,不适用于 Firstname space LastName ,当我运行此查询时,我只会得到0个文档

This only works for a query by the FirstName but not for FirstName "space" LastName, when I run this query I just get 0 documents

示例:

名字 John Doe

Name John Doe


  • John,我得到了所有Johns的建议

  • John,我得到所有约翰的建议

  • John D,我得到0个文档

  • John Doe,我得到1个文档

  • John, I get suggestions for all Johns
  • John , I get suggestions for all Johns
  • John D, I get 0 documents
  • John Doe, I get 1 document

这是我的代码:

term = Uri.EscapeDataString(term);
SuggestParameters sp = new SuggestParameters
{
    Top = 20,
    UseFuzzyMatching = true,
    SearchFields = new List<string> { "FirstName", "LastName","Email" },
    Select = new List<string> { "Id","FirstName", "LastName", "Email" },
    OrderBy = new List<string> { "FirstName", "LastName", "Email" },
};
var docs = await _indexClient.Documents.SuggestAsync(term, "sg", sp);




  • 我可以按一个词来拆分查询吗?
    第二个是姓氏?

  • 我需要用不同的方式来代替术语吗?

  • 是否可以使用任何通配符来实现类似SQL中的 Like expresion 之类的行为?

    • Can I split the query by terms like one to be the FirstName andthe second one to be the LastName?
    • Do I need to scape the term in a different way?
    • Is there any wildcard I can use to have a similar behavior like a Like expresion in SQL?
    • 任何帮助将不胜感激

      推荐答案

      回答您的问题:


      • **我可以按一个名字(如姓和第二个名字)来拆分查询吗?**

      • **Can I split the query by terms like one to be the FirstName and the second one to be the LastName?**

      为说明起见,请不要使用以下示例:

      For Illustration, let't take below example:

      POST /indexes/Flights/docs/search?api-version=2019-05-06
      {
          "search": "First Class, Spacious Seats* +\"Emirates\"",
          "searchFields": "description, title",
          "searchMode": "any",
          "filter": "price ge 60 and price lt 300",
          "orderby": "geo.distance(location, geography'POINT(-449.476235 11.212349)')",
          "queryType": "full"
      }
      

      对于此请求,搜索引擎将执行以下操作:

      For this request, the search engine does the following:


      • Fi筛选出价格至少为$ 60且小于$ 300的文档。

      • 执行查询。在此示例中,搜索查询由词组和术语组成:头等舱,宽敞座位* + \酋长国\(用户通常不输入标点符号,但在示例中包含标点符号可以让我们解释分析器的用法处理它)。对于此查询,搜索引擎将在searchFields中指定的描述和标题字段中扫描包含酋长国以及头等舱或以 Spacious Seats开头的词语的文档。对于不需要显式要求(+)的条件,可以使用searchMode参数匹配任何条件(默认)或所有条件。

      • Filters out documents where the price is at least $60 and less than $300.
      • Executes the query. In this example, the search query consists of phrases and terms: "First Class, Spacious Seats* +\"Emirates\"" (users typically don't enter punctuation, but including it in the example allows us to explain how analyzers handle it). For this query, the search engine scans the description and title fields specified in searchFields for documents that contain "Emirates", and additionally on the term "First Class", or on terms that start with the prefix "Spacious Seats". The searchMode parameter is used to match on any term (default) or all of them, for cases where a term is not explicitly required (+).

      订单到给定地理位置的距离,得到的一组航班,然后返回到调用应用程序。

      Orders the resulting set of flights by proximity to a given geography location, and then returned to the calling application.

      我相信,这样您就可以进行 ** OR ** 的搜索。

      I believe , by this way you will be able to do **OR** based search.


      • 我需要用另一种方式代替字词吗?

      与上面相同

      是否可以使用任何通配符来实现类似SQL中的Like表达式这样的行为?

      Is there any wildcard I can use to have a similar behavior like a Like expresion in SQL?

      您可以参考

      参考:

      希望有帮助。

      这篇关于在Azure搜索中(一个以上)提出多个建议或两个建议之间的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 04:11