# Searching for negative numerical values?

**URL:** <https://forum.litium.com/t/searching-for-negative-numerical-values/112>\
**Category:** Questions\
**Tags:** search\
**Created:** [June 15, 2018, 8:23am UTC](https://forum.litium.com/t/searching-for-negative-numerical-values/112 "2018-06-15T08:23:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hans](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/hans/32/31_2.png) [@hans](https://forum.litium.com/u/hans)\
**Post date:** [June 15, 2018, 8:23am UTC](https://forum.litium.com/t/searching-for-negative-numerical-values/112/1 "2018-06-15T08:23:23Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [July 4, 2018, 11:17am UTC](https://forum.litium.com/t/searching-for-negative-numerical-values/112/2 "2018-07-04T11:17:50Z")

</div>

I got it to work using [rangetag](https://docs.litium.com/documentation/architecture/search/range-search):

```auto
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)_

---

<div class="post-metadata">

**Author:** ![hans](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/hans/32/31_2.png) [@hans](https://forum.litium.com/u/hans)\
**Post date:** [July 4, 2018, 12:12pm UTC](https://forum.litium.com/t/searching-for-negative-numerical-values/112/3 "2018-07-04T12:12:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [July 4, 2018, 12:37pm UTC](https://forum.litium.com/t/searching-for-negative-numerical-values/112/4 "2018-07-04T12:37:27Z")

</div>

> [@hans](#):
>
> that’s a workaround I guess 🙂

Definitely a workaround 🙂, 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.
