2

I have an index :

from rest in docs 
from prom in rest.RestPromotions

When querying with LuceneQuery the TotalResults is more than expected because of the duplicate documents created by the index. The skipped field has only the skipped results from the current page.

Is there a way to get the distinct total results?

The document type is like this:

{
  "RestName": "Belini",
  "RestID": 1275,
  "SearchNotVisible": [
    "Beliny",
    "bellini"
  ],
  "RegionID": 4,
  "SubRegionID": 0,
  "CityID": 172,
  "AreaID": 5,
  "AvgPriceID": 3,
  "RestTypes": [
    58
  ],
  "FoodTypes": [
    1,
    16
  ],
  "RestSpecials": [],
  "RestProperties": [
    4
  ],
  "RestPromotions": [
    {
      "regionID": 4,
      "cityID": 172,
      "areaID": 0,
      "KosherID": 0,
      "foodTypeID": 16,
      "restTypeID": 0,
      "promotionNumber": 1,
      "isFalsePromo": false
    },
    {
      "regionID": 4,
      "cityID": 172,
      "areaID": 0,
      "KosherID": 0,
      "foodTypeID": 0,
      "restTypeID": 0,
      "promotionNumber": 1,
      "isFalsePromo": false
    },
    {
      "regionID": 4,
      "cityID": 172,
      "areaID": 0,
      "KosherID": 0,
      "foodTypeID": 1,
      "restTypeID": 0,
      "promotionNumber": 1,
      "isFalsePromo": false
    },
  "isKosher": false,
  "ReviewsScore": 3.709,
  "ReviewsAmount": 408,
  "Latitude": 32.060707,
  "Longitude": 34.765018
}

and when doing a LuceneQuery on the index :

from rest in docs 
from prom in rest.RestPromotions
select new {RestID=rest.RestID,RestName=rest.RestName,PromoCityID=prom.cityID}

the TotalResult is greater than the real amount of documents returned by the query. I know this is because of duplicated documents that are made by the index.

What I want to know is if there is an option to get the real amount of distinct documents that a specific LuceneQuery has generated.

4

1 回答 1

0

将您的索引映射更改为:

from rest in docs 
select new
{
    rest.RestName,
    PromoCityID = rest.RestPromotions.Select(x=> x.cityID)
}

这将在一个索引条目中索引多个术语,而不是具有多个索引条目。您仍然可以像以前一样查询单个术语。但是现在当您查看统计数据时,TotalResults将表示匹配的餐厅总数。

于 2013-01-24T16:37:06.100 回答