1

As shown in the picture, I have some tokens in a computed field and want to search all those fields which have { }, but not able to do so, although I have put escape sequence i.e.

enter image description here

I have tried to execute the same from Sitecore and have not been able to find any records as well. After looking into Solr query find that it removes { from search text, as shown below

enter image description here

So should we assume that we can't search {} in Solr or there is any workaround for it?

enter image description here

6
  • Search query seems correct, are you getting results with an exact match. like apiurl_t:"exact string" Mar 3 at 13:59
  • yes. for apiurl_t: yyy, getting string MF/v2/productdetail/BreakpointPricingHistory/67065R812/{yyyy-mm-dd}
    – Rinku Jain
    Mar 3 at 14:02
  • can you try this apiurl_t: " * \{ * " .Comments don't allow me to put a star (*). so I've used space after star. but basically try query without spaces before and after * Mar 3 at 14:28
  • i have already tried it, you can see that in screenshot in question
    – Rinku Jain
    Mar 3 at 14:44
  • yep, just put double quotes as well before after Asterisk. Mar 3 at 15:01

1 Answer 1

2

As far as I can tell from your screenshot, your field type is text_general that uses StandardTokenizerFactory (like this):

  <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="false">
    <analyzer type="index">
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
      <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
    <analyzer type="query">
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
      <filter class="solr.SynonymFilterFactory" expand="true" ignoreCase="true" synonyms="synonyms.txt"/>
      <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
  </fieldType>

Indexing: your { } characters are ignored by StandardTokenizerFactory on indexing level and are used to tokenize your text.

I don't see a reason to use text_general for URLs, why you don't use string?

If you really need text_general for your field: best option is to create your own field type with your specific tokenizer behavior (instead of changing text_general schema). You can use WhiteSpaceTokenizer, PatternTokenizerFactory, KeywordTokenizerFactory depends on your needs instead of StandardTokenizerFactory.

Quering: your workaround by using \ for escaping should work for quering. But your text_general field type uses the same StandardTokenizerFactory for querying, so your { } are also escaped from your query.

So, best solution is to change your field type to string. If you cant do it by some reasons - implement your own field type with needed tokenizers on indexing and querying levels.

P.S. I am not 100% sure for querying with {, as far as I remember it was a bug in old Sitecore versions with Lucene search that Sitecore force calls Lucene QueryParser.Escape on query time, but I hope it was fixed a long time ago and it works fine with querying without StandardTokenizerFactory.

1
  • Thanks @x3mxray, i am able to search using { now in Solr url, although not able to search { in CMS, as i guess there we can't give field name to search from.
    – Rinku Jain
    Mar 6 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.