Searching for negative numerical values?

Are there any issues with indexing and searching for document properties with negative numeric values?

It seems like we have a problem where we don’t find e.g. pages using the Lucene search when looking for negative page property values (e.g. -123). If the value is positive it works as expected.

Steps to reproduce:

  1. Create a numerical pagetype property
  2. Publish a page where the numerical page property has a negative value, e.g. -123
  3. Run a search like:
    var q = new QueryRequest(languageId, SearchDomains.Pages, SecurityToken.AnonymousToken);
    var c = new MandatoryTagClause();
    c.Tags.Add(new Tag(TagNames.GetTagNameForProperty("foo"), -123));
    q.FilterTags.Add(c);
    var r = Solution.Instance.SearchService.Search(q);
    // r.TotalHitCount => 0
    
  4. Number of hits is zero

Litium version: 4.8.8

I got it to work using rangetag:

var query = new QueryRequest(webSite.Language.ID, SearchDomains.Pages, _token);
var range = new RangeTag(TagNames.GetTagNameForProperty("foo"), -123, -123);
query.FilterTags.Add(range);
var response = Solution.Instance.SearchService.Search(query);

(tested on version 6.2 but should also work fine in version 4.8)

Thanks, that’s a workaround I guess :slight_smile:
(We “solved it” by padding the indexed values with a string prefix and treating the value as a string, which worked in this case.)

Definitely a workaround :slight_smile:, but possibly a bit cleaner one than modifying the stored value?

I was unable to actually search for the negative value directly, tested with different analyzers.