2013-07-03 38 views
1

我使用一把umbraco搜索詞,我已經檢查並運行但是我的查詢詞已經剝離出來檢查剝離出來

例如:

我「在月球上的人」與搜索下面的代碼行中,變量「搜索關鍵詞」應該包括「人在月球上」:

var Searcher = ExamineManager.Instance.SearchProviderCollection["MySearcher"]; 
var searchCriteria = Searcher.CreateSearchCriteria(); 

var query = searchCriteria.Field("Name", searchTerm).Compile(); 

然而,查詢,因爲這時候我調試生成:

{ SearchIndexType: , LuceneQuery: +Name:"man moon" } 

請注意它是如何從searchTerm中刪除「on the」字樣的?

推測這是因爲它們被認爲是STOP /保留字。但是,這意味着我沒有得到我期望的搜索結果。

我該如何解決這個問題?

回答

2

在內部,StopAnalyzer類被StandardAnalyzer用作標準索引過程的一部分。 StopAnalyzer(http://lucenenet.apache.org/docs/3.0.3/d7/df5/_stop_analyzer_8cs_source.html#l00054)包含一種方法,允許您將不同的停用詞集替換爲ISet類型參數,而不是使用標準ENGLISH_STOP_WORDS_SET(第134行)。

和我讀到這裏(http://webcache.googleusercontent.com/search?q=cache:sA-uyAC015UJ:our.umbraco.org/m%3Fmode%3Dtopic%26id%3D25600+&cd=2&hl=en&ct=clnk&gl=uk),您可以得到通過檢查一組空停止字添加下面一行到你的Application_Start方法在Global.asax中

Lucene.Net.Analysis.StopAnalyzer.ENGLISH_STOP_WORDS_SET = new System.Collections.Hashtable(); 

因此,要使用空的停止字你月球上的人應該回來。

有點奇怪的想法,但作爲一種選擇,你也可以添加一個StopAnalyzer ExamineSettings.config創建只有停用詞的文檔索引,然後與你的標準分析結果集進行聯繫?