我正在使用Sitecore 8.1更新1和ContentSearch功能。我将索引配置如下:
(我想按纬度和经度搜索经纪人/客户办公室)
1)在index.config
中 <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="latitude" storageType="NO" indexType="UNTOKENIZED" vectorType="NO" boost="1f" type="System.Decimal" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
</field>
<field fieldName="longitude" storageType="NO" indexType="UNTOKENIZED" vectorType="NO" boost="1f" type="System.Decimal" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
</field>
2)好的,现在使用Luke.net工具检查其值
3)我的SearchResultItem类:
[IndexField("latitude")]
public decimal Latitude { get; set; }
[IndexField("longitude")]
public decimal Longitude { get; set; }
4)在我的服务类中,我想尝试在方法之间搜索范围内的纬度/经度,但它不起作用。我尝试等号(==)方法,它的工作原理。我认为我的索引还可以,但我的搜索语法可能有问题。你能帮忙吗?
//TODO: Testing -----------------
var query = searchContext.GetQueryable<BrokerSearchIndexItem>();
// IF i use this line (BETWEEN) --> NOT work ??
query = query.Where(item => (item.Latitude.Between(-34, -33, Inclusion.Both)
&& item.Longitude.Between(149, 151, Inclusion.Both)));
// If I use this line (EQUAL) --> work !
//query = query.Where(item => item.Latitude == -33.737643m && item.Longitude == 150.856664m);
var searchResult = query.GetResults();
5)我已经阅读了这篇教程(link)和我的搜索日志,似乎在方法之间给我正确的日志,但不确定为什么我什么也得不到
9636 21:10:03 INFO ExecuteQueryAgainstLucene (steadfast_broker_location): +latitude:[-34 TO -33] +longitude:[149 TO 151] - Filter :
9636 21:10:03 INFO ExecuteQueryAgainstLucene (steadfast_broker_location): +latitude:[-34 TO -33] +longitude:[149 TO 151] - Filter :
9636 21:10:03 INFO ExecuteQueryAgainstLucene (steadfast_broker_location): +latitude:[-34 TO -33] +longitude:[149 TO 151] - Filter :
答案 0 :(得分:0)
查看Lucene Spatial Search Support module
它将提供: