Reputation: 1923
i want to get record for a period in solr
my url is
http://localhost:8090/solr/select?q=xyz=Vehicles per KM of record Road&version=2.2&start=0&rows=200&indent=on&omitHeader=true&wt=json&sort=timestamp desc
and my response is
{
"response": {
"numFound": 4,
"start": 0,
"docs": [
{
"xyz": "some record one",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-07T10:41:29.544Z",
"id": [
"e1d1865-1402-ef20-6880-9262d6e7d22"
]
},
{
"xyz": "some record two",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-06T10:34:53.799Z",
"id": [
"99eab5aa-c83b-e90b-e548-6d09e94c9ba2"
]
},
{
"xyz": "some record three",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-03T09:05:45.521Z",
"id": [
"84fba82a-2ae6-eaa8-1b37-79c842c9e96"
]
},
{
"xyz": "some record four",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-01T09:05:45.521Z",
"id": [
"84fba82a-2ae6-eaa8-1b37-79c842c9e96"
]
}
]
}
}
I am getting some problems
1.in my search query sentence is "Vehicles per KM of record Road". but am getting records which doesn't have.
it suppose to come one record only
{
"xyz": "Vehicles per KM of record Road",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-01T09:05:45.521Z",
"id": [
"84fba82a-2ae6-eaa8-1b37-79c842c9e96"
]
}
2.I want to get records for particular periods example from 2014-11-08 to 2014-11-05
in this case only two records should come
{
"xyz": "some record one",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-07",
"id": [
"e1d1865-1402-ef20-6880-9262d6e7d22"
]
},
{
"xyz": "some record two",
"ids": "an22f17b87-3c75-4b77-9300-9039a9fe63f2",
"timestamp": "2014-11-06",
"id": [
"99eab5aa-c83b-e90b-e548-6d09e94c9ba2"
]
}
but i am getting all records please help me out
Upvotes: 0
Views: 86
Reputation: 52832
Depending on the field types, the second question should be a date interval filter (as long as it's date field .. although it would probably work with string fields as well):
timestamp:[2014-11-05 TO 2014-11-09]
You might have to tweak those values to get the correct cut off (but I think 11-09 should be 2014-11-09 00:00:00, meaning that only entries from earlier than that date should be included).
For the first part, it depends on your query parser. If the parser is dismax
, the mm
clause and the default boolean operator will determine how the search is done. You do not want xyz=
there, unless it's part of the data you're searching for (searching in a specific field would be field:
).
Use the analysis page in Solr administration to see why you're not matching what you're looking for (enter the content indexed and the search string, which should give you a more detailed view of what Solr is doing internally for each step).
Upvotes: 1