Zend_Search_Lucene and range search - zend-framework

I have a bunch of int key fields in my index and trying to do a simple range search like this:
`gender:1 AND height:[120 TO 180]`
This should give me male in the height range 120 to 180. But for some reason i get this exception:
`At least one range query boundary term must be non-empty term`
How would i debug this? Is it just Zend_Search_Lucene being buggy?

This is an open bug in the query parser of the Zend Framework. Created in december 2008 with high priority... and still unsolved.

First, you have to change default Analyzer to TextNum to allow number before finding
ZF2:
\ZendSearch\Lucene\Analysis\Analyzer\Analyzer::setDefault(new \ZendSearch\Lucene\Analysis\Analyzer\Common\TextNum\CaseInsensitive());
Second, your date field MUST be a keyword, not text.

Related

MS Access use DATE() in a calculated field

I am using Microsoft Access 2016. I am trying to find out how many years exist from the current year until a future year. I have a column that is end_date. I am trying to create a calculated field that is essentially YEAR(end_date) - YEAR(current_year). I tried to use YEAR(DATE()) but DATE() is not allowed to be used in a calculated field apparently.
Is there no way to do a calculation like this?
Nope. Calculated fields are cached and static, so are NEVER allowed to contain ANY information that will change over time, due to system settings, or anything else that is not directly entered in that row.
However, you should not be using calculated fields anyway. See http://allenbrowne.com/casu-14.html, among many posts advocating for not using calculated fields.
Instead, use queries to do calculations. That way, you won't have any trouble using the current date, and won't have to deal with the possible errors and portability issues calculated fields come with.
I changed my thinking to calculate this in a form. It does not seem good practice to have a field in a DB that changes everyday.
In a form, you can use this expression as controlsource for a textbox:
=DateDiff("yyyy",Date(),[EndDate])
However, that return the difference in calendar years. To find the count of full years, use a function like AgeSimple and this expression:
=AgeSimple([EndDate])

Drupal date range indexing with Apache Solr

i am using these drupal modules
search_api
search_api_solr
date_range_formatter
views
and in fact many other modules to get my Solr / Drupal project going to index ~100000 nodes of content.
The setup is working great, BUT i need to get search results from the Solr for a date range field and this is where i am stuck.
Somehow i am stuck with setting up the correct operator "between" and "not between" and using "<=" or ">=" is causing trouble here.
I can't get my Solr-query like
field[1 TO *] AND field[* TO 10]
to work.
One content type can have multiple date ranges when available for searching.
The user can search for a start date and an end date. The daterange should match inside each individual daterange of the indexed entity type.
Let's say it is valid from:
2015-10-01 to 2015-10-10
2015-11-01 to 2015-11-10
...
and so on.
To get me going and sort the problems the right way i need to know first:
What is the best practise to store a date range inside Drupal to index at the Solr side? Is a date range a good way or would is better to store a range with a value for each day individually like:
2015-10-01
2015-10-02
2015-10-03
...
What is the best for Solr to index a date range?
What field type inside Drupal would you suggest to store the values inside an entity type to be able to send it to Drupal?
I know i am not the first struggeling with this. Details can be found here:
https://www.drupal.org/node/1783746
but onfortunately none of these patches were error free to my setup. I tried all out to get this going. Now i am looking for any advice, sum ups or thoughts that might be helpful to track down my last bits of errors.
Any advice or idea is really appreciated.
Thanks.
This is not a step by step solution. I just want to give you an idea how to adapt this to your project and still stay compatible with search_api and search_api_solr:
One possible solution could be to store and index the dates from an entity in one field per date individually as
2015-10-01
2015-10-02
2015-10-03
...
after this use
function mymodule_search_api_views_query_alter(
view &$view,SearchApiViewsQuery &$query) {
...
}
}
to add missing query conditions like
AND field_name = 2015-10-01 (as timestamp)
AND field_name = 2015-10-02
AND field_name = 2015-10-03
to take care of all conditions.
I hope this is helpful to someone who is in need of a similar solution.

Is it possible to extend Firebird table name length?

I'm a Firebird newbie here. I'm trying to use Firebird Embedded from an ASP.Net application. Everything connects fine but I'm running into problems with the length of column names. I'm trying to create a table named "Orchard_Framework_DataMigrationRecord." I keep getting an exception which says "Name longer than database column size." After some investigation, I've seen that a number of people have mentioned that Firebird has a column name length limit of 30 characters.
Is that correct and if so is there any way to change it? In my case, I can't change the name of the table; it really has to be that long.
Unfortunately there is no way to change the maximum identifier length, it's an implementation limit. There is a plan to remove this limitation but in current version (2.5) the max identifier length is 31 characters.
This appears to be fixed as of Firebird version 4.0 Alpha 1: Increase maximum length of object names to 63 characters

Numeric Overflow in crystal report

I have a numeric field in my report that I perform the operation
Time({Command.EndTime}/60,Remainder({Command.EndTime},60),0)
on.
Basically the field is a time field but my predecessor used a numeric field to represent it for some unknown reason. The field is the number of minutes past midnight. For example: 60 is 1am, 65 is 01:05 am...) I would like to report it in a form that is more human friendly. However, I got this error "Numeric overflow" and wonder what might have caused it. Normally, the cause of this error is a division by zero but the divisor is clearly 60.
If I just used {Command.EndTime}, the report was fine... The database is huge with millions of records, so scanning the report line by line is only my last resort. Is there a way to know what was wrong in the data or better yet get around the error mentioned above?
Thanks!
The first parameter to Time() has to be a whole number. Try this instead:
Time(Truncate({Command.EndTime}/60),Remainder({Command.EndTime},60),0)

Get the last date of non-empty value using MDX

Do you know how to get the last non-empty value using mdx query.. then after that.. i want to count how many null values are next to it up to the last date. My main purpose for this is to count how many days a customer has no transaction..
i have to make a report in ssrs (using adventure works cube) that counts how many days a customer has no transaction..
thanks..
Use this article to obtain set of non empty dates.
To obtain count you can:
Use member properties (day of year or something more suitable in
this case) and just subtract one value from another.
You can find
last date with non empty value, previous one using LAG(1), include
them to the next construction {prev.date:last.date} and use COUNT
for set
Recently I follow this article, It really helps me.
The most important part is to understand scope usage.
Even If you don't have an Enterprise Edition, you can use it.