Using the wrong escape character for Lucene lexical error at line 1 Cannot Parse Encountered <EOF>. Kentico 12

China☆狼群 提交于 2019-12-13 18:03:33

问题


I have a similar issue as the following question: Lucene error while parsing Query: Cannot parse '': Encountered “” at line 1, column 0, and I had already tried all the escaping. What else could it be?

I'm using Kentico 12 hotfix 14, with their Lucene.NET 3.0.3 implementation. My Smart Search Index uses the Standard analyzer, see below:

I get the expected rows back when I use the following lucene syntax to pull back an en-US culture result. This syntax is automatically created by Kentico and is needed to retrieve the correct culture. This was directly copied from the property value.

"+_culture:([en-us TO en-us] [invariantifieldivaluei TO invariantifieldivaluei])"

When I add (or use alone) the following value (in many different forms - without parenthesis, etc):

 "+length:(24\")"

I always get the Lexical error:

"Cannot parse '+_culture:([en-us TO en-us] [invariantifieldivaluei TO invariantifieldivaluei])  +length:(24\")': Lexical error at line 1, column 95.  Encountered: <EOF> after : \"\\\")\""

As you can see, I believe that I have escaped the value for the length correctly. What am I missing here?

Other values, that don't require escaping work just fine, such as:

+material:(nitrile)

Any thoughts on what I'm doing wrong with the 24" value? Wrong analyzer? Needed Kentico hotfix? Wrong order of filters? Thanks for your time!


回答1:


Seems I'm not the first to deal with this within Kentico, and found the following helper method: CMS.Search.SearchSyntaxHelper.EscapeKeyWords(string). I applied this method to my specific search filter values and it's working as expected! Lots of good methods within the parent class too, check them out.



来源:https://stackoverflow.com/questions/56447549/using-the-wrong-escape-character-for-lucene-lexical-error-at-line-1-cannot-parse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!