Dharmik Bhandari
Dharmik Bhandari

Reputation: 1702

How to handle special character in filter in SolrNet?

I'm working on SolrNet 3.6 which is used in e-Commerce site based on ASP.NET MVC3 with C#.

There is one filter called "cpu socket type" and its values are

  1. AM2+
  2. AM3+
  3. AM2

Solr is working properly when you filter with "AM2" but it is not working when you filter with "AM2+" or "AM3+". At same time we can not get any result or an error also. I know that this issue is related with special character but don't know how to handle this?

Upvotes: 1

Views: 1231

Answers (1)

Paige Cook
Paige Cook

Reputation: 22555

According to the SolrNet Wiki Page on Querying, try using the SolrQueryByField method as:

It also has the benefit that it handles special character escaping for you.

So your code would look similar to this, assuming your field was named cpusockettype in your solr schema.xml file.

ISolrOperations<Item> solr = ...
var items = solr.Query(new SolrQueryByField("cpusockettype", "AM2+"));

Upvotes: 3

Related Questions