Reputation: 153
I am running an app basically creating a URL shortener and when I setup the "shorurl" which is upper and lower case I cannot get a Query or a Filter to find it. However for other fields that are more simple it works just fine. I tried doing lower case on it not sure really how to match.
Here is the field definition:
[ElasticProperty(Name = "shorturl", IncludeInAll = true)]
public string ShortUrl { get; set; }
Here is an example:
string url = "http://test.com/JjdWtPoV";
FilterContainer filter = new FilterContainer();
filter = Filter<Data>.Term("shorturl", url);
var results = this.Client.Search<Data>(s => s
.Filter(filter)
);
QueryContainer q = new QueryContainer();
q = Query<Data>.Term("shorturl", url);
results = this.Client.Search<Data>(s => s
.Query(q)
);
results = this.Client.Search<Data>(s => s
.Query(f => f.Term(p=> p.ShortUrl, url))
);
I should note the following is what versions I'm using:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Elasticsearch.Net" version="1.3.1" targetFramework="net45" />
<package id="NEST" version="1.3.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net45" />
</packages>
FOUND THE ANSWER Need to ensure a string has "NOT ANALYZED" set
[ElasticProperty(Name = "shorturl", IncludeInAll = true,
Index=FieldIndexOption.NotAnalyzed)]
public string ShortUrl { get; set; }
Upvotes: 1
Views: 576
Reputation: 153
[ElasticProperty(Name = "shorturl", IncludeInAll = true,
Index=FieldIndexOption.NotAnalyzed)]
public string ShortUrl { get; set; }
Upvotes: 2