By RichieMN

2019-06-04 16:03:56 8 Comments

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:

enter image description here

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):


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:


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!


@RichieMN 2019-06-11 14:00:38

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.

Escaped value in code

Escaped value in text visualizer

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] How to implement MoreLikeThis feature in Lucene.NET?

1 Answered Questions

[SOLVED] javaparser - Lexical error Encountered: <EOF> after : ""

1 Answered Questions

[SOLVED] Lucene - Sorting Date as NumericField

6 Answered Questions

[SOLVED] Keyword (OR, AND) search in Lucene

  • 2009-08-21 11:00:06
  • Areca
  • 9412 View
  • 18 Score
  • 6 Answer
  • Tags:   java lucene

1 Answered Questions

[SOLVED] neo4j: lucene ParseException: cannot parse 'bbox'

1 Answered Questions

1 Answered Questions

1 Answered Questions

[SOLVED] What is wrong with this Lucene query?

Sponsored Content