Is there any difference between the 2 solutions? Is it more/less
efficient to change the index so that the field is "NotAnalyzed"?
For anyone else looking at this 1 thing caught me out:
If you field is a Int32 then you need this query
(string.Format("0x{0:X8}", number))
http://localhost:8080/indexes/PostIndex?Query=PostTypeId:0x00000002
If it's Int64 (string.Format("0x{0:X16}", number))
http://localhost:8080/indexes/PostIndex?Query=PostTypeId:0x0000000000000002
On May 17, 6:06 pm, Ayende Rahien <
aye...@ayende.com> wrote:
> Matt, yes, it is.
> You need to use the following logic to be able to query on numbers:
> string.Format("0x{0:X16}", number)
>
> We need this is to allow range queries.
>
> Alternatively, you can specify in your index definition that this field in
> NotAnalyzed, which will allow to query on it directly
>
> On Mon, May 17, 2010 at 5:59 PM, Matt Warren <
mattd...@googlemail.com>wrote:
>
> > I have the following document (only relevant fields shown);
>
> > {
> > * ViewCount: 0
> > * CreationDate: "/Date(1267396921443+0000)/"
> > * OwnerUserId: 188414
> > * PostTypeId: 2 //this is an integer not a string
> > .......
> > }
>
> > And I create the following index:
> > docs.Posts.Select(doc => new {PostTypeId = doc.PostTypeId})
>
> > then hit this Url
> >
http://localhost:8080/indexes/PostIndex?Query=PostTypeId:2
> > I get no results returned.
>
> > However if I change the index query to:
> > docs.Posts.Select(doc => new {PostTypeId =
> > doc.PostTypeId.ToString()})
>
> > then the queryhttp://localhost:8080/indexes/PostIndex?Query=PostTypeId:2,