Reputation: 3
My data in user.created_at field is like below
Tue Mar 10 23:03:00 +0000 2020
Tue Mar 10 04:29:18 +0000 2020
Tue Jan 21 08:45:43 +0000 2020
Tue Mar 10 00:11:45 +0000 2020
Tue Jan 28 04:11:45 +0000 2020
Sun Mar 08 10:19:19 +0000 2020
And I tried to Query ES like:
{
"query": {
"bool": {
"must": [
{
"match": {
"sentiment": "neutral"
}
}
,
{
"wildcard": {
"user.created_at": "*2020"
}
}
,
{
"match": {
"user.created_at": "Tue Mar 10"
}
}
],
"must_not": [ ],
"should": [ ]
}
}}
But there is also show another datas which is that I don't want too. The result keep showing other date. Like below
Keep Showing other date, not what I want
My Question is, how do I return only one data with date Tue Mar 10 23:03:00 +0000 2020 specifically ? Is there any way to get only 1 hits data with that specific date. I don't have any idea about this. Please help me.
Upvotes: 0
Views: 187
Reputation: 3
I have solved my own problem. I am using a long Query to get the specific hits with long date value in a field.
{
"query": {
"bool": {
"must": [
{
"match": {
"sentiment": "neutral"
}
}
,
{
"wildcard": {
"user.created_at": "*2020"
}
}
,
{
"match": {
"user.created_at": "Tue"
}
}
,
{
"match": {
"user.created_at": "Mar"
}
}
,
{
"match": {
"user.created_at": "10"
}
}
,
{
"match": {
"user.created_at": "Tue Mar"
}
}
,
{
"match": {
"user.created_at": "Mar 10"
}
}
],
"must_not": [ ],
"should": [ ]
}
},
"from": 0,
"size": 250,
"sort": [ ],
"aggs": { }
}
Upvotes: 0
Reputation: 16905
What's your created_at
's mapping type? When it's a date
, you can use a range
query with the correct date format:
...
"query": {
"range": {
"user.created_at": {
"gte": "2020-03-10",
"lt": "2020-03-11"
}
}
}
...
Upvotes: 1