I have a problem that i want to get total count of matched text in solr.
but when i want to perform search using solr i have to set max rows parameter. can anybody explain how i could get the total matched count using solr efficiently?
You can get the total result count, independently from max rows defined, through the numFound attribute in the Solr response.
Related
I am using Kibana version v7.13.2.
I am trying to search for messages carrying the phrase "amount":"3000","taxRate"
where the amount value ranges from 3000 to 3999.
I am using the following Lucene Query:
message:amount /3[0-9]{3}/ taxRate
The query works and fetches the following:
"amount":"3100","taxRate"
"amount":"200","taxRate"
"amount":"3983","taxRate"
"amount":"3100"
"taxRate"
"amount"
"3100","taxRate"
"amount":"3100","trxFee":"90","taxRate"
Means the query is working with OR condition. It fetches the messages if there is word amount OR the number ranging from [3000-3999] OR the word "taxRate".
I want to modify the query to search for messages where ALL THREE PATTERNS exist together IN THAT SPECIFIC ORDER, i.e. first amount second amount value and finally the word taxRate
So with the correct query, the following resultSet would appear only:
"amount":"3100","taxRate"
"amount":"3983","taxRate"
Kindly help.
I using the laravel framework and i am trying to get the max date for each address and display it.But it doesn't work as i expected,with max it doesn't bring me back the correct row.
$locations = \DB::table('mesaurement')
->select(\DB::raw('mesaurement.ID as ID,mesaurement.Latitude,mesaurement.Longitute,mesaurement.Temperature as temp,mesaurement.Humidity,mesaurement.Pressure,mesaurement.address, mesaurement.created_at,max(created_at) as date'))
->orderby('date','desc')
->groupby('mesaurement.address')
->get();
I wanted with the max date to bring me back the right Temperature,Humidity etc. I grouped by address because i have a lot of the same addresses and i want them to be just one.
i am unaware of the framework but the query can be simple as below
select max(temp) from mesaurement
group by mesaurement.address;
more details with multiple columns in max can be found at below link
Multiple max values in a query
So here is what I am trying to do.
I have a facet defined on the price field.
1) When there is a query for "wordA"
I want the facets to be from 0-1000 divided in 5 intervals since my maximum price for "wordA" will never exceed 1000
2) When there is a query for "wordB"
I want the facets to be from 0-50 divided in 5 intervals since my maximum price for the query "wordB" will never exceed 50.
So basically I want the facet range to change dynamically so that I don't end up with a range of 0-1000 for a query "wordB" where all the hits will lie in the 1st range.
If solr does not support this then it will be a lot of query post processing involved to modify the ranges based on the returned results.
Solr does not support that, but you can do it yourself by doing two queries - first get the stats (max, min) for the field, then submit a query for the facet ranges (intervals) that are suitable for your application.
I am trying to count the total unique number of heating complaints in the Socrata NYC 311 service requests database: https://data.cityofnewyork.us/Social-Services/All-Heat-complaints-to-311/m5nm-vca4
Ideally I want to use the data to populate a map with unique complaints, as well as the number of complaints by each unique address. So far I have used the following query which only returns about 2 days of data:
http://data.cityofnewyork.us/resource/m5nm-vca4.json?$select=created_date,longitude,latitude,COUNT(*)&$group=created_date,longitude,latitude&$where=complaint_type=%27heating%27
Is there anyway to query the database for unique address across all dates and count them by total complaints?
Can you be a little more descriptive about what you're trying to get? An example of the output you're trying to get would be perfect.
I think we might be able to get what you're looking for, but we need to get the aggregation right.
We are using two solrs to index the files. Sometimes one article is indexed in both solrs because we do update. It cause a problem that the facet counts are not correct due to these duplicated articles. How can I de-duplicate the counts?
My advise would be not to keep duplicated articles. So you need a method to identify this duplicates articles and deleted it form one SOLR.
If you don't want to delete duplicate articles you still need to keep track of them.
Knowing which articles from SOLR1 are duplicates in SOLR2 will help you de-duplicate the counts like this:
create an extra field in SOLR1 named :
IsDuplicateField = true, if article is duplicated in SOLR2
= false, otherwise
when you do the query to SOLR1 add: IsDuplicatedField=true to facets.
when retrieving result just decrease the total number of facet counts with total number of IsDuplicateField from SOLR1.
In this situation the facet IsDuplicateField will retrieve all the articles that are duplicated and match your query.
Good luck !