Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在c代码中定义AzureSearch索引字段映射_Azure_Search_Indexer_Azure Cognitive Search - Fatal编程技术网

在c代码中定义AzureSearch索引字段映射

在c代码中定义AzureSearch索引字段映射,azure,search,indexer,azure-cognitive-search,Azure,Search,Indexer,Azure Cognitive Search,我想用C语言编程定义JSON对象和Azure搜索索引之间的字段映射。我在这里找到了关于如何在Javascript中实现这一点的解释 但是我需要c等价的代码。到目前为止,我已经尝试过: var index = new { name = "testindex", fields = new [] { //... }, fieldMappin

我想用C语言编程定义JSON对象和Azure搜索索引之间的字段映射。我在这里找到了关于如何在Javascript中实现这一点的解释

但是我需要c等价的代码。到目前为止,我已经尝试过:

      var index = new
      {
           name = "testindex",
           fields = new []
           { 
              //...
           },
           fieldMappings = new[]
           {
              new { sourceFieldName = "/status/text", targetFieldName = "text"}
           }
      }
但这段代码崩溃了,只有一个例外

{"Azure Search request failed:{\"error\":{\"code\":\"\",\"message\":\"The request is invalid. Details: index : The property 'fieldMappings' does not exist on type 'Microsoft.Azure.Search.V2015_02_28.IndexDefinition'. Make sure to only use property names that are defined by the type.\\r\\n\"}}"}
关于如何用C代码编程定义这些字段映射,有什么建议吗?此外,这些字段映射是否应该在索引定义的索引器中定义?谢谢大家!

@LaterEdit:在本文中,我发现必须在索引器上定义这些映射,但如果在定义索引器时添加它们,则属性字段映射仍然不存在

  var indexer = new
  {
      name = "textixr",
      dataSourceName = "testsdocdb",
      schedule = new { interval = "PT5M" }, // every 5 minutes
      targetIndexName = "test",
      fieldMappings = new []
      {
          new { sourceFieldName = "/status/text", targetFieldName = "text" }
      }
  };

您需要使用api版本2015-02-28-Preview。2015-02-28中没有字段映射


顺便说一下,只有在使用blob indexer索引JSON blob时,才能使用带有JSON指针(如/status/text)的字段映射。它们不能与DocumentDB索引器一起使用。要使用DocumentDB投影嵌套属性,请在数据源定义的container.query属性中使用类似SQL的查询。有关DocumentDB indexer的更多信息,请查看您需要使用api版本2015-02-28-Preview。2015-02-28中没有字段映射


顺便说一下,只有在使用blob indexer索引JSON blob时,才能使用带有JSON指针(如/status/text)的字段映射。它们不能与DocumentDB索引器一起使用。要使用DocumentDB投影嵌套属性,请在数据源定义的container.query属性中使用类似SQL的查询。有关DocumentDB indexer的更多信息,请查看

谢谢您的回复。2015-02-28-预览未给出错误。但是,我不确定如何在container.query属性中使用类似Sql的查询。您可以给我举个例子,或者让我看一篇提到这一点的文章吗?在定义数据源时,您需要使用SQL查询来展平您的文档,例如选择c.id、c.\u ts、c.status.text作为集合c中的文本,其中c.\u ts>=@HighWaterMark。我链接到的文章有一些例子。谢谢!我目前正在用C语言编程创建DocumentDb数据库、AzureSearch索引器和索引器,有没有办法用C语言调用此语法?您是指使用.NET SDK为数据源指定查询?是的,使用属性:dataSource.Container.Query=一个查询。感谢您的回复。2015-02-28-预览未给出错误。但是,我不确定如何在container.query属性中使用类似Sql的查询。您可以给我举个例子,或者让我看一篇提到这一点的文章吗?在定义数据源时,您需要使用SQL查询来展平您的文档,例如选择c.id、c.\u ts、c.status.text作为集合c中的文本,其中c.\u ts>=@HighWaterMark。我链接到的文章有一些例子。谢谢!我目前正在用C语言编程创建DocumentDb数据库、AzureSearch索引器和索引器,有没有办法用C语言调用此语法?您是指使用.NET SDK为数据源指定查询?是,使用属性:dataSource.Container.Query=查询。
  var indexer = new
  {
      name = "textixr",
      dataSourceName = "testsdocdb",
      schedule = new { interval = "PT5M" }, // every 5 minutes
      targetIndexName = "test",
      fieldMappings = new []
      {
          new { sourceFieldName = "/status/text", targetFieldName = "text" }
      }
  };