Get total record count for a query in zend lucene search? - zend-framework

HI
I have used "setResultSetLimit(1000)" method to limit results to 1000 records. The good thing is It helps to save server resources, but there is noway to get full record count for a query. Is any one know how to get full hit count?
TX

Its not possiblie within my tries...
I suggest u to make a full search store results making a cache file maybe or session and use zend_paginator array adapter

The answer is so easy or I didn't understand the question ?
$results = $index->find("saerch term");
echo count($results); // you will get count

Related

Microsoft Cognitive Services - Bing News Search API V5. So many misunderstanding

I'm working on an app that use the Bing news API. We are currently using the V2 but we want to update it to V5.
We have a problem with the TotalEstimatedMatches attribute. This count is updated radomly when we try to iterate with the offset.
Sometimes the data are not relevant. or when we try to sort the results by date, the dates are not well sorted.
Is there someone who did it ? I really need help.
Thank's !
You should only integrate the very 1st TotalEstimatedMatches return value and use that as a constant maximum-bound while you use the 'count' & 'offset' params to iterate through pages of the same query. I use python primarily so I will here.
If:
TotalEstimatedMatches == 250,000
in the response returned from the first 50 results of your query. Then if you wanted to get a massive list of ALL 250,000 links you would do something like:
# Assuming count==50 & offset==0
max_bound = 250000
results = []
while offset <= max_bound-50:
results.append(your_search_function(your_query, count, offset, **stuff))
offset += count
If you were to keep doing offset calculations using the new TotalEstimatedMatches attribute generated after each query, you'll start skipping pages.
As far as the date-ranges go, I'm less sure. I think I read they're adding better functionality there soon.

Emberjs not returning all records

I am using the SANE stack, which consists of Sails and Emberjs. I am also using MongoDB as a datastore.
When I do something like the following on the Sailsjs side of things;
Parent.find(req.query.id).populate('children').exec(function(err, parent){
console.log('children.length = ' + parent[0].children.length);
});
I get 212
But when I do something like the following on the Emberjs side of things;
parent.get('children').then(function(children){
console.log('children.length = ' + children.length);
});
I get 30.
As a matter of fact, once the number of records goes over 30, it does not matter ember will only return 30 records.
Is there some way to get the rest of the records? I actually need to records so I can sort and calculate some things. I am not just displaying them.
Any help would be greatly appreciated.
Explanation
That's because the default response limit in Sails is 30 records. It's there obviously so that if you have 10k or a million rows you don't make some normal request and accidentally dump out your entire database to the client and crash everything.
This is documented here:
http://sailsjs.org/documentation/reference/configuration/sails-config-blueprints
defaultLimit (default: 30)
The default number of records to show in the response
from a "find" action. Doubles as the default size of populated arrays
if populate is true.
It's also documented in the config/blueprints.js file in your sails app:
https://github.com/balderdashy/sails-generate-backend/blob/master/templates/config/blueprints.js#L152-L160.
Here is the relevant code: https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/actionUtil.js#L291
Solution
Edit the defaultLimit in your config/blueprints.js file
OR
Add &limit=<number> to your http request URL

nxlog querylist doesn't work as expected

nxlog.conf
The above link is to a copy of my nxlog.conf. I couldn't find any documentation about how to use multiple blocks within a querylist block, but based on the name I assumed that I would be able to do this. My ELK server is receiving ALL events right now, not any of the filtered ones. I wanted to just use one query block but it is limited to 10 select entries. I can't find any examples of people using more than like 3 select entries. Has anyone had any luck with more advance nxlog.conf's? Any help would be appreciated.
Not sure what the issue with the query xml is. If there is a limitation on the number of select entries, that's coming from the Windows Eventlog API so that cannot be helped.
On the other hand you can use nxlog's native filtering using drop():
Query <QueryList>\
<Query Id="0">\
<Select Path="Security">*</Select>\
</Query>\
</QueryList>
Exec if not ($EventID == 1 or $EventID == 2 or ...) drop();
actually there is no issue with the XML. I was viewing old results in my database from when I was testing nxlog.conf with no queries. My bad!

Sphinx search debugging

We use Sphinx Search at work but and I am having an issue with a new index I'm setting up. Does anyone know of a tool or technique that so I can look at the data stored in Sphinx?
Basically I want to do something like - "show me the first 5 records in index 'X'", just to be sure that it is actually storing data. At the moment I'm about 90% sure that my query code is correct but have no way of knowing that my index is correct.
Cheers
*SELECT * FROM index_name* on Sphinx side should give you a list of IDs. This required MySQL protocol support to be enabled in Sphinx conf file:
listen = 9306:mysql41
To Find Ids in index, you can do this:
/usr/local/sphinx/bin/indextool -c /usr/local/sphinx/etc/sphinx.conf --dumpdocids indexname

Zend_Paginator - Increase querys

I started using Zend_Paginator,
it works everything fine but I noticed that there is one more query which slows the load time down.
The additional query:
SELECT COUNT(1) AS `zend_paginator_row_count` FROM `content`
The normal query:
SELECT `content`.`id`, `content`.`name` FROM `content` LIMIT 2
PHP:
$adapter = new Zend_Paginator_Adapter_DbSelect($table->select()->from($table, array('id', 'name')));
$paginator = new Zend_Paginator($adapter);
Could I merge the two querys into one (for better performance)?
Make sure you have an index on one or more int-based columns of the selected table. So the count query will not have much of a performance inpact. You can use setRowCount() to provide the count (if you have it).
From http://framework.zend.com/manual/en/zend.paginator.usage.html :
Note: Instead of selecting every
matching row of a given query, the
DbSelect and DbTableSelect adapters
retrieve only the smallest amount of
data necessary for displaying the
current page. Because of this, a
second query is dynamically generated
to determine the total number of
matching rows. However, it is possible
to directly supply a count or count
query yourself. See the setRowCount()
method in the DbSelect adapter for
more information.
Merging the two wouldn't really have much of a performance increase if any. The actual select content has the limit statement in it (as you are trying to get a subset of the entire table in the database) where the count needs to count all rows in the database. The reason it is done like this is to prevent having to select a very large set of data simply to get the count.