English 中文(简体)
我如何在认知中找到独特的价值观?
原标题:How do I get distinct values in Azure Cognitive Search for pagination?
  • 时间:2023-09-01 02:20:31
  •  标签:
  • azure

I ve been stuck with this problem for a few weeks now and I have no idea how to solve it. So basically, my index contains data that looks something like this:

[
    { id: 1, value: "some snippet from a paragraph"},
    { id: 1, value: "some different snippet from the same paragraph" }.
    { id: 1, value: "some different snippet from the same paragraph" },
    { id: 2, value: "some snippet from a different paragraph" },
    { id: 2, value: "some different snippet from id no.2 s paragraph " },
    ... and a few more million values
]

如你所知,“一款”分为多层。 每个项目都有相同的识别资料,但具有不同的价值。

I used $top and $skip, but the problem with this is that the values in the top n results will contain "duplicates". Like, the top 50 results will contain multiple items that have an ID of 1. What I want to happen is that the top n results should only contain items with unique ID s. Is it possible to just get the item with the highest score of each ID? How can I make this happen?

成果应如此:

[   
    { id: 1, value: "some value" },
    { id: 2, value: "some value" }.
    { id: 3, value: "some value" },
    { id: 4, value: "some value" },
    { id: 5, value: "some value" },
    ... 
]
问题回答

Have you considered modeling your schema so that each paragraph is a string element in a Collection(Edm.String) field? Each document would look like this:

{
 "id": 1,
 "paragraphs": [
    "some snippet from a paragraph",
    "some different snippet from the same paragraph",
    "some different snippet from the same paragraph"
 ]
}

You can still target the "paragraphs" field with your query, but this will guarantee each top-level documents on appears once in your search results (regardless of how many "paragraph" matched the query).

这里与“支持数据类型”网页链接:https://learn.microsoft.com/en-us/rest/api/searchservice/support-data-types





相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签