I'm just curious why Lucene doesn't distinguish string and numeric values in a standard way.. for example ['2' TO '6'] and [2 TO 6] for range queries and treat all of them by default as String.
Is there any particular reason to treat both of these cases as the string values?
Your range query example is based on lucene query syntax. In this definition it's not defined in what kind of field type you execute this query.
Basically if you apply this query to a TextField the evaluation will be based on String. If you apply this to a IntPoint the number will be interpreted as integer. Responsible for this is the QueryParser in which you add your query and your field you like to search.
In your case using an IntPoint would make sense because you want to search for an numeric range.
More details about the query parser see QueryParser Javadoc
Related
I am reading conflicting explanations of the Like operator.
I understand that this is a String operator that compares two string expressions. By that definition, should it not only work on fields with text data types, and not on numeric or date/time fields?
However, when I test the Like operator in a query (in Query Design view), it is able to compare non-string data types. This is confusing.
Can someone please explain if this is a string operator or not?
This is OT here. However, the answer is very simple:
When applying Like to a field or variable that is not text, its value will first be casted to localised text - like what you would see if you from CStr(SomeValue).
Thus, here where the decimal separator is comma, this will filter out all values for a decimal field:
Like "*.*"
and this will filter out all integer values:
Like "*,*"
I'm applying the following Lucene query predicate in order to get all inclusive numbers in 2 to 6 range:
value:[2 TO 6]
and receive the documents with the following values:
567986400000
567986400000
567986400000
536450400000
536450400000
599608800000
536450400000
567986400000
I'm interested in the numeric range query and obviously, for example, the Long value 567986400000 is not in the range of [2 TO 6]. Looks like the range searches are strings and I don't know how to workaround it in mine application for the different numeric values.
How to properly use numeric range queries in Lucene?
To achieve a proper range query you need to use specific defined fields from lucene. See Field javadoc
IntPoint: int indexed for exact/range queries.
LongPoint: long indexed for exact/range queries.
FloatPoint: float indexed for exact/range queries.
DoublePoint: double indexed for exact/range queries.
So you need to be sure that your field you add this query is one of this types. As you said you use a Neo4j generated lucene index. There has to be an option to create this kind of fields otherwise you're not able to execute proper range queries.
I want to sort my column numbers at report level in SSRS instead of my query as I have some other columns sorted at query level and doing both sorts at query level don't work well. At the moment I get Columns order like 1, 10,2,3,4,5,6 instead of 1,2,3,4,5,6...10.
Once sorting is done I also want to add 'sales_' to the column name so I see sales_1, sales_2, sales_3 and so on. I understand this could be pretty straightforward but I'm new to SSRS. Thanks in advance.
The sort you are describing (1, 10,2,3,4) is a string sort, you need to convert the data type on that column to a numeric (in this case integer) type so that the sort is correct.
There are two solutions to this, you can add a calculated field to the record set, this can be helpful if you need to use this column multiple times, or you can simply use an expression for the sort order.
Right click on your dataset and select Add Calculated field, a dialog will open with all the column definitions for the query, here you can add your own custom fields.
For a custom field you will need an expression, which was the other options originally, so lets have a look at that component.
Edit the sort definition for the Tablix or group and select the field you want to sort on, to sort the way you would like the value needs to be numeric, we can use the CInt function to convert a value to an integer
NOTE: when using expressions to convert data types, if your data might not be convertible you may need to validate the value before conversion otherwise your
report execution will fail. The error messages are pretty helpful though and the expression dialog shows available functions an examples of usage for each of them.
For your second issue, use an expression in the field where you are displaying the data to concatenate the values, you can use the String.Format function or you can use simple string addition:
Expression Examples:
="sales_" + Fields!ItemValue.Value
="sales_" & Fields!ItemValue.Value
=String.Format("sales_{0}", Fields!ItemValue.Value)
I hope this helps you on your way, welcome to SSRS!
I have a collection of strings and want to filter out those where the last four characters are: (alpha)(alpha)(number)(number).
I know I can make a substring of each of these and separately, but what is the method to determine the types of the characters in the sequence?
This is for SQL in Hive.
You can use regular expressions. Something like:
where col regexp '[a-zA-Z]{2}[0-9]{2}$'
I put some fields like manufacturer, group, description, num.
SimpleFaceted works ok if I use query like sometext* with QueryParser.
Im trying to use num:[100 TO 200],
num is NumericField with SetIntValue(150).
I got nothing returned.
Am I missing something?
You can't use a normal query parser for numeric range queries. However, assuming you know at query time which fields are numeric, it isn't too hard to derive a class from the Lucene query parser and create numeric range queries as necessary.
Support for numeric queries in the standard query parser looks like it should be available in Lucene.Net when a port of v3.4 is available. (See Java Lucene issue 1768)
Good luck,