Search for -1 in Solr - search

I have an optional property of type pfloat, that can either be an encoded numeric value, or -1 if the property is not set. Numerics are encoded to be range searchable (1 is encoded to something like 10000000001), but -1 will always be -1.
How can I search a field for -1?
property:-1 throws parse error and property:'-1' doesn't return anything.
Thanks for help!

Use double quotes: property:"-1"

Try:
*:* NOT property:[0 TO *]

Related

How to search for a value in one long string?

I'm currently trying to filter a value from a long string I got by using a GET request with the cURL command. The output looks like this:
{"errors":null,"result":{"host_id":"1632","display_name":"notshownhere","hostname":"notshownhere","dnsname":"","ip":"1.1.1.1","host_type_id":"1","checks":[{"check_id":"12851","preset_id":"1","checktype_id":"1","checktype_short_name":"ping","status":"3","status_condition":"ok","status_color":"green","status_change_time":"1589066121","result_short":"1.1.1.1 is alive","result_time":"1591683892"}
My aim is to filter out the host_id from this output. This means, I want to find a way how I can only output the host_id with the number 1632.
I tried out Select-String, but it didn't work because the string is too long.
This looks like JSON and it would be best to use ConvertFrom-Json command on a proper JSON. That results in a PowerShell object where you could use object.'host_id' to retrieve the value.
Parsing the string, you can do the following.
# Assuming $j contains your string
($j | Select-String -Pattern '(?<="host_id":")\d+(?=")').Matches.Value
Since -pattern by default take a regex string, (?<=) contains a positive lookbehind from the current position. (?=) is a positive lookahead. \d+ is one or more digits. Since the command returns a MatchInfo object, you need to access the Value to return the digits.

Create new bit column based on string evaluation

I was looking into the function Contains but it can only be used in the Where predicate, what I'm looking for is something of the sorts
Select doc.* , IsSync = StringContains('Sync', doc.Url) from vw_Doc as doc
IsSync now would contain 1/0 or true/false, depending if the word Sync exists in the document Url.
Is this at all possible ?
Thank you for your time
Edit: StringContains is meant as a pseudo-function, it's not valid syntax
I would use case and charindex().
select
doc.* ,
case
when charindex('Sync', doc.Url) > 0
then 1
else 0
end as IsSync
from
vw_Doc as doc
Contains is not limited to a where clause, it returns a boolean that can be used in various contexts, e.g.:
select *,
case when Contains( doc.url, 'Sync' ) then 1 else 0 end as IsSync
from vw_Doc;

how to pass date value into my url using python

htmlfile=urllib.request.urlopen("https://hermes.goibibo.com/hotels/v2/search/data/v3/6771549831164675055/{pickUpDate}/{dropOffDate}/1-1_0?s=popularity&cur=INR&f={}&pid=0".format(pickUpDate=pickUpDate, dropOffDate=dropOffDate))
You have three {} pairs but 2 values in your URL. You need to match the {} pairs with the given values.
For instance:
"{v1} is {v2}. {v3}".format(v1="Cat", v2="Animal", v3="Absolutely!")
the string is "Cat is Animal. Absolutely!"
At the end of your string you have "..INR&f={}&pid=0".format().
If this is not a placeholder into which you want to place text via .format(), then change it to have double moustache brackets. i.e:
"...INR&f={{}}&pid=0".format()
This will tell .format() that you really just want the brackets to exist there as a string
So, in general:
>>"{x}: {}".format(x="Hello")
IndexError: tuple index out of range
but
>>"{x}: {{}}".format(x="Hello")
'Hello: {}'
htmlfile=urllib.request.urlopen("https://hermes.goibibo.com/hotels/v2/search/data/v3/6771549831164675055/"+pickUpDate+"/"+dropOffDate+"/1-1_0?s=popularity&cur=INR&f={}&pid=0")

Do we have any methods in mel to check string contained in some another String or not

Do we have any methods in mel to check string contained in some another String or not.
For Example:
I had String like "mel".
I had Another String like "melcode".
Do we have any idea how to check the String "mel" is available in String "melcode".
num indexOf(str inputString1, str inputString2)
if the return value is -1 then inputString1 does not contain inputString2
As mentioned in Is there any possible way to filter movelets using mel from another movlet?
Hi Jaya Sankar, you can use indexOf which returns -1 if the first input String does not contain the second input String. There are also startsWith and endsWith as methods.

SQL Server Varchar to VarBinary Conversion

I have to insert the string "johnmelling" value into a table which has the column as
[USERPASS] varbinary NOT NULL.
Please could any one suggest me, what would be the best conversion to insert "johnmelling"?
I tried to to insert as below,
Insert into table(column1)
Values(CONVERT(varbinary(1), 'johnmelling'))
Then I got the error
Line 1: String or binary data would be truncated.
Thank You,
You are converting to varbinary(1) so your target datatype is varbinary but the integer you have specified in parentheses is 1 which means your datatype will only have a length of 1; you are receiving that error because the length you have allocated to that datatype is too small. The literal, 'johnmelling' is 11 characters but you are trying to store it in a datatype that has a length of 1.
Simply change the integer in parentheses to 11, 50, 255, max or whatever you think is an appropriate length and you won't get that error.

Resources