我正在使用Sitecore 8.1更新1與ContentSearch功能。配置我的指標如下:Sitecore內容搜索(Lucene) - 之間<T>()不工作
(我想通過經緯度搜索經紀人/客戶辦公室)
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 :
不確定,但嘗試'-34.000000m'而不是'-34'。 或作爲解決方法,這應該有所幫助: query = query.Where(item =>(item.Latitude> -34.000000m && item.Latitude <-33.000000m)&&(item.Longitude> 149.000000m && item.Longitude <151.000000m )) –