在文档类型下过滤Lucene搜索结果

问题描述 投票:0回答:2

我有如下结构

类别(靴子)

---- itemsForSale(adidas)

类别(袜子)

---- itemsForSale(长)

其中Boots是类别doctype的名称,Adidas是itemsForSale doctype等的名称。

现在,如果网站的访问者从复选框选项中选择Boots类别,我会将ID传递给搜索页面

访问者还可以通过关键字和最小,最高价格进行搜索。

关键字min,max price选项有效,我只是无法使搜索工作,因此它只显示父项下的项目,即Addidas。

我有以下代码:

ExamineIndex

<add Name="categoryPath"/>

OnGatheringNodeData

private void SetCustomSearchParameters(object sender, IndexingNodeDataEventArgs e)
    {
        var path    = e.Fields["path"];
        path        = path.Replace(",", " ");
        e.Fields.Add("categoryPath", path);
    }

我的搜索如下:

 //TODO needs to be fixed so that checkbox search can be done
                    query = searchCriteria.Range("bidPrice", paddedLower, paddedHigher, true, true).And().Field("categoryPath",searchCategory).Or().Field("nodeName",searchCategory.Fuzzy()).Or().Field("nodeName", q.Fuzzy()).Or().Field("description", q.Fuzzy());

但没有结果返回,任何人都可以看到我做错了什么,我重建索引,但没有运气,当在后台搜索时,我的categoryPath没有显示。

我读过以下http://www.attackmonkey.co.uk/blog/2011/12/limiting-an-examine-search-to-the-current-site

https://our.umbraco.org/forum/using-umbraco-and-getting-started/88502-limiting-examine-search-to-one-page-and-its-children

------------- ----------------索引集

<IndexSet SetName="AuctionSearch" IndexPath="~/App_Data/ExamineIndexes/AuctionSearch">
    <IndexAttributeFields>
      <add Name="id" />
      <add Name="nodeName"/>
      <add Name="updateDate" />
      <add Name="writerName" />
      <add Name="nodeTypeAlias" />
    </IndexAttributeFields>
    <IndexUserFields>
      <add Name="description"/>
      <add Name="image"/>
      <add Name="name"/>
      <add Name="bidPrice" EnableSorting="true" Type="DOUBLE"/>
      <add Name="searchBidPrice" EnableSorting="true" Type="DOUBLE"/>
      <add Name="numberOfBids"/>
      <add Name="category"/>
      <add Name="itemsForSale"/>
      <add Name="bidEndDateTime"/>
      <add Name="categoryPath"/>
    </IndexUserFields>
    <IncludeNodeTypes>
      <add Name="itemsForSale" />
    </IncludeNodeTypes>
  </IndexSet>
umbraco lucene.net umbraco7
2个回答
0
投票

我想你想要使用的是.GroupedOr,你尝试过这样的东西吗?

query = searchCriteria.Range("bidPrice", paddedLower, paddedHigher, true, true)
    .And().Field("categoryPath",searchCategory)
    .And().GroupedOr(
        new string[] { "nodeName", "nodeName", "description"}
      , new[]{ searchCategory.Fuzzy(), q.Fuzzy(), q.Fuzzy() }
    )
;

0
投票

如果其他人遇到这个问题,所有在线示例都将“路径”显示为“路径”或创建我在我的情况下执行的别名,但它不起作用

在我的情况下,只有在我使用__Path时才能过滤父项下的子项

工作守则

query = searchCriteria.Range("bidPrice", paddedLower, paddedHigher, true, true).And().Field("__Path", programParent.MultipleCharacterWildcard()).And().GroupedOr(new[] {"description", "nodename"}, q.Fuzzy()).Compile();
© www.soinside.com 2019 - 2024. All rights reserved.