2012-11-06 37 views
0

我想与ravendb方面的能力,但获得奇怪的结果。方面与ravendb

我有像证件:

{ 
    "SearchableModel": "42LC2RR ", 
    "ModelName": "42LC2RR", 
    "ModelID": 490578, 
    "Name": "LG 42 Television 42LC2RR", 
    "Desctription": "fffff", 
    "Image": "1/4/9/8/18278941c", 
    "MinPrice": 9400.0, 
    "MaxPrice": 9400.0, 
    "StoreAmounts": 1, 
    "AuctionAmounts": 0, 
    "Popolarity": 3, 
    "ViewScore": 0.0, 
    "ReviewAmount": 2, 
    "ReviewScore": 45, 
    "Sog": "E-TV", 
    "SogID": 1, 
    "IsModel": true, 
    "Manufacrurer": "LG", 
    "ParamsList": [ 
    "1994267", 
    "46570", 
    "4134", 
    "4132", 
    "4118", 
    "46566", 
    "4110", 
    "180676", 
    "239517", 
    "750771", 
    "2658507", 
    "2658498", 
    "46627", 
    "4136", 
    "169941", 
    "169846", 
    "145620", 
    "169940", 
    "141416", 
    "3190767", 
    "3190768", 
    "144720", 
    "2300706", 
    "4093", 
    "4009", 
    "1418470", 
    "179766", 
    "190025", 
    "170557", 
    "170189", 
    "43768", 
    "4138", 
    "67976", 
    "239516", 
    "3190771", 
    "141195" 
    ], 
} 

其中ParamList各自代表了产品的属性,并在我们的应用中有什么样的缓存每个PARAM表示。

当搜索特定的产品时,我想计算所有返回的属性,以便能够在搜索后添加每件物品的数量。

在电视类别搜索LG之后,我想:

帕拉姆:4134女巫是LCD的一个代表和金额:65。

但不幸的是我得到了奇怪的结果。只有一些参数被计数,有些则没有。 在一些搜索者,我得到的结果回来我没有得到任何数额回来。

我使用的是RavenDB的最新稳定版本。

指数:

from doc in docs 
from param in doc.ParamsList 
select new {Name=doc.Name,Description=doc.Description,SearchNotVisible = doc.SearchNotVisible,SogID=doc.SogID,Param =param} 

小面:

DocumentStore documentStore = new DocumentStore { ConnectionStringName = "Server" }; 
     documentStore.Initialize(); 
     using (IDocumentSession session = documentStore.OpenSession()) 
     { 
      List<Facet> _facets = new List<Facet> 
         { 
          new Facet {Name = "Param"} 

         }; 

      session.Store(new FacetSetup { Id = "facets/Params", Facets = _facets }); 
      session.SaveChanges(); 
     } 

使用例如:

IDictionary<string, IEnumerable<FacetValue>> facets = session.Advanced.DatabaseCommands.GetFacets("FullIndexParams", new IndexQuery { Query = "Name:lg" }, "facets/Params"); 

我尝试许多变化都没有成功。

有没有人有想法我做错了什么?

感谢

回答

0

使用该指数,它应该解决您的问题:

from doc in docs 
select new {Name=doc.Name,Description=doc.Description,SearchNotVisible = doc.SearchNotVisible,SogID=doc.SogID,Param = doc.ParamsList} 
+0

谢谢,我在发布前尝试这个选项。但不幸的是也没有为我工作。 –