strdist function stopped recognizing field reference in SOLR 5 - solr

I remember in previous SOLR version (4.x) I was able to run the following query:
"(lastName:HILL)"
with fields
"*,score, strDistLastName:$lnamestrdist"
and with raw query params
"lnamestrdist=strdist('HILL',lastName,jw)"
This would give me result with an additional field which is result of strdist function using Jaro Winkler algorithm between a value and returned field.
For some reason in SOLR version 5.1 it always returns 0, even if strings match 1 to 1 (i.e. strdist should be 1).
I have checked it without using variables, i.e. only specifying fields as
"*,score, strdist('HILL',lastName,jw)"
but it also returns 0.
And only when I use another string literal like below, it returns 1:
"*,score, strdist('HILL','HILL',jw)"
I assume it means that strdist does not recognize fields anymore. Does anyone know why? Maybe syntax has changed or it's simply a bug?
Thank you very much in advance!

My bad, I have "solr.LowerCaseFilterFactory" filter in index/query analyzers for the "lastNameExact" field, therefore value for strdist for 'HILL' and 'hill' was 0. After I corrected fields list to "*,score, strdist('hill',lastName,jw)", strdist became 1.
Sorry for the confusion :)

Related

Is it possible to un-localize MSSQL-results in VBS?

Sorry if I'm using the wrong terminology - I'm not into MSSQL or VBScript.
I have a given script implementing a SQL query containing
.. AND (rep.is_primary_replica is null or rep.is_primary_replica = ''True'' or rep.is_primary_replica = ''False'') ..
which returns no results on a German server only because rep.is_primary_replica seems to contain ''Wahr'' and ''Falsch'' instead of ''True'' and ''False''
This question is about an at least similar problem.
Unfortunately there is no wtf flag.
Is there a way to do that correctly?
Can I disable localization of string conversions? (in MS SQL Server? VBS?)
Don't let printed values in the script confuse you. There is an implicit conversion from original value to string which depends on the client's (VBScript in your case I think) locale.
Type of the field is_primary_replica here must be bit if the rep is an instance of sys.dm_hadr_database_replica_states view.
If this is the case, it's pointless to check a bit field is Null, or its value equal to True or False, there's no other possibility anyway.
It appears that you can safely remove this condition from the query.
If you insist to include it, use number literals instead.
AND (rep.is_primary_replica is null or rep.is_primary_replica = 1 or rep.is_primary_replica = 0)
This is the proper way to query a bit field. With this way the server's or client's locale configuration won't cause any problems.

Value Being Loaded As NULL to SQL Server When It Is A Zero And Other Than Zero It Is Working Fine via Informatica PowerCenter 10.1

I have come through a scenario where the value for a field is loading 'NULL' when actual value in the file is '0' but loading the correct value if the file has a non-zero value. I have used the debugger and read the session log. Everywhere the value is showing '0', but in the table it is loading as 'NULL'. Is this a known issue? Can anyone please help me overcoming this discrepancy.
Did you try writing the output to a file and see the output ? Please give details of the transformation.
In addition, Informatica has a special property which you can set when value is 0 or when value is null.
Check that session property too.
Check if there is anything present when value is 0.
Also, what is the column datatype which you are trying to populate too? Does that column have any constraint to not to accept "0"? check that too.
I agree (as #buzyjess says), writing the output to a text file will make it easy for debugging. So, please let us know how it looks like when you output to a file.

scala readCsvFile behaviour

I´m using flink to load a csv file to a dataset of pojos, defined through a scala case class, using readCsvFile method, and I have a problem that i cannot solve.
When in the csv there is a record with some format error in any of its fields it is discarded, and I assume that the only way to keep those records is to type them all as String and do the validations myself.
The problem is that if the last field after the delimiter is empty, the record is discarded by default, I think because it is considered as not having the expected number of fields it should, and it is not possible to handle this record error, while if the empty value if in any of the previous fields there is no problem.
Example
field1|field2|field3
a||c
a|b|
In this example, first record is returned by readCsvFile method but not the second.
Is this behaviour right? and there is any walk around to get the record?
Thanks
Case classes and tuples in Flink do not support null values. Therefore, a||c is invalid if the empty field is not a String. I recommend to use the RowCsvInputFormat in this case. It supports nulls and generic rows can be converted to any other class in a following map operator.
The problem is that, as you say, if the field is a String, the record should be valid even if it is null, and this doesn't happen when the null value is in the last field. The behaviour is different depending on the position.
I will try also with RowCsvInputFormat as you recommend.
Thanks

Detect when (Select All) is checked for multi value parameter

I have a report with a multi-valued parameter on it. I'm looking to output the selected values which is accomplished with Join(Parameters!State.Label,",")
Every solution I've found on the web indicates I should use something like the following to detect when the (Select All) "value" is selected.
E.g. expression for the text box on the header should be:
="State: " & IIF(countrows("prc_prompt_state").Equals(Parameters!State.Count),"(All)",join(Parameters!State.Label,","))
CountRows() tells me the total number of parameters available, e.g. 8 states in Australia. Parameters!State.Count is supposed to tell me how many are actually selected by the user. However this always reports the full value (8 in this case) regardless of how many are selected. This is in agreement with the official docs (https://technet.microsoft.com/en-us/library/aa337293(v=sql.100).aspx), but NOT in agreement with every single search result I come up with on how to solve this problem.
So how can I rewrite this expression so I can find out when (Select All) is/isn't checked? I'm using report builder 3, which I believe is based on the 2008 edition - we deploy to Azure, but I haven't got that far yet.
Examples of questions whose answers seem to be wrong:
Displaying Multi-Value Parameters
SSRS: Can I know if user selected "ALL" in multivalued param?
This is old, but google found it for me, and then I figured out an answer on my own that worked. (I was using a list of users.)
I created a separate dataset that returns a count of all available options in the default parameter lookup (username). Then, I assigned that as a default value to an internal parameter. (UserCount) This worked as a text expression:
=Microsoft.VisualBasic.Interaction.IIF(Parameters!username.Count = Parameters!UserCount.Value, "All Selected", Microsoft.VisualBasic.Strings.JOIN(Parameters!username.Value, ", "))

Using another field value as default in a solr function query

I'm trying to run the following query:
/solr/select?q=_val_:query("{!dismax qf=text v='solr rocks'}", my_field)
But, specifying my_field as the default value throws the error:
java.lang.NumberFormatException: For input string: "my_field"
Additionally, these queries also fail:
/solr/select?q=_val_:query("{!dismax qf=text v='solr rocks'}", ceil(my_field))
/solr/select?q=_val_:query("{!dismax qf=text v='solr rocks'}", ceil(1.0))
Can we not specify another field or function as the default in function queries? Is there another way to accomplish what I'm trying to do?
I'm using Solr 3.1.
According to the code of the ValueSourceParser for QueryValueSource (line 261), the 2nd argument of query can only be a float. So 3 or 4.5 would work, but my_field or ceil(1.0) which are ValueSources instead of constants would not.
I don't know what your use case is, but would taking max(query("{!dismax qf=text v='solr rocks'}"), my_field) be good enough? (Provided that my_field has positive values, the result would only differ from what you are trying to do when the score of the query is lower than the value of my_field)
Otherwise, if you really need this feature, it should be fairly easy to implement your own function based on QueryValueSource in order to take a ValueSource as the 2nd argument instead of a float.
I did find an alternate way to mimic the desired logic:
/solr/select?q=_val_:sum(query("{!dismax qf=text v='solr rocks'}"),product(map(query("{!dismax qf=text v='solr rocks'}",-1),0,100,0,1), my_field))
A little roundabout way to do it, but works fine.

Resources