Escaping Special Characters in Import for Neo4j - neo4j

In my where clause I am trying to escape a special character "#" by following the manual's recommendation regarding backticks when creating a node:
WHERE line.`The #` IS NOT NULL AND line.`Person's First/Last Name` IS NOT NULL
However, when I do this, I get message:
No data returned, and nothing was changed.
Am I escaping the header values ("The #" and "Person's First/Last Name") properly?

This example code works for me, doesn't look like your problem is the escape characters.
CREATE (n:TestNode { `The #`:"123", `Person's First/Last Name`:"john johnson" });
MATCH (line)
WHERE line.`The #` IS NOT NULL AND line.`Person's First/Last Name` IS NOT NULL
RETURN line.`The #`, line.`Person's First/Last Name`;
line.`The #` line.`Person's First/Last Name`
123 john johnson
Returned 1 row in 128 ms

Related

Rails query to substitute field and query

could someone please help me to write a query to substitute hyphens in rails DB field with space?
For eg:
If I have a field called 'name' in a table User having a value 'asdc-sd bc', and want to remove special characters like '-' and replace it with space to match with a given name 'asdc sd bc'.
I tried using lower to convert the name to lowercase but am not able to find out how to substitute the hyphens with space. Please help!
You can use SQL REPLACE function to replace - with spaces(' ').
For example, if you are querying on name column of User model, you can write your query like below:
query_str = 'asdc sd bc'
User.where("REPLACE(name, '-', ' ') = ?", query_str)

QUERY - Google Sheets - filter with conditions

I'm trying to filter some rows of this sheet
Google sheet sample image
I'm using the following query:
=query(Jira_query!$A:$I;"SELECT A WHERE E contains '&SDP&' AND C IN ('To Do','In Progress')")
But I'm only getting this error:
Error
PARSE_ERROR: Encountered " "C "" at line 1, column 39. Was expecting one of: "(" ... "(" ...
I would appreciate some help here, thanks!
Get rid of the ampersands before and after SDP. That is a string literal and should just be sitting between the single quotes.
In addition, I don't think QUERY supports IN; instead, use MATCHES with a pipe-separated list.
Finally, you only need to reference A:E in the QUERY, since you don't reference any columns beyond E in the SELECT clause.
So try this:
=QUERY(Jira_query!$A:$E;"SELECT A WHERE E CONTAINS 'SDP' AND C MATCHES 'To Do|In Progress'")

[splunk]: Obtain a count of hits in a query of regexes

I am searching for a list of regexes in a splunk alert like this:
... | regex "regex1|regex2|...|regexn"
Can I modify this query to get a table of the regexes found along with their count. The table shouldn't show rows with 0 counts.
regex2 17
regexn 3
The regex command merely filters events. All we know is each result passed the regular expression. There is no record or indication of why or how any event passed.
To do that, you'd have to extract a unique field or value from each regex and then test the resulting events to see which field or value was present. The regex command, however, does not extract anything. You'd need the rex command or the match function to do that.
Looks like | regex line is not needed. This is working for me. Notice the extra brackets.
| rex max_match=0 "(?P<countfields>((regex1)|(regex2)|..|(regexn)))"
| stats count by countfields

Resolve DGET function "More than one match found" error

I am trying to match a list of range with certain criteria in a google spreadsheet. I am using DGET function for the same. Everything is working fine but the problem comes when there are many entries that contain the whole string and I receive "More than one match found in DGET evaluation.".
For the better understanding look below:
Sheet "Form Responses 1":
B
-------
Ronald
Ronaldo
Ronaldinho
Rebarto
Matching sheet entries:
A
------
Ronald
Rebarto
Juhino
My Formula is:
=DGET('Form Responses 1'!B:H,"Date",{"Email Address","Logging In or Logging out ?","Date";A2,$B$1,$H$1})
Now the problem is Ronald is matching with "Ronald","Ronaldo" and "Ronaldinho" and I am receiving the error which says "multiple entries found".
How do we solve this?
I solved the problem by Concatenating a constant variable before and after the name. For example Ronaldo becomes mRonamdom and Ronald becomes mRonaldm. This makes the Names Unique and solves the problem.
If you don't want to modify the data but to fix the formula so it doesn't get confused with similar entries in your database parameter you can add a character to the criteria field of the dget function as shown below (I'm using an '=' sign concatenated to the value I want to match with in the database parameter)
=dget(database!$A$1:$B$11,$M$1,{"columnName";"="&F2})
where
A1:B11 is my database
M1 is the matching column name
and "="&F2 is the field with the caracter I chose that I want to match with to retrieve values from the matching database column, now even if the there are more than one matches found (becuase matching substrings"), the addition of the caracter contatenated with the matching value, should take care of the in-accurate error.

fuzzy search using cypher

I have node for user with FirstName, LastName properties. Now I want to search some value in both properties from both site. Let I have to explain.
FirstName LastName
--------- --------
Manish Pal
Pal Dharmesh
Rajpal Yadav
sharma shreepal
Now I want to search which node's firstname or lastname contain 'pal'.
I have written query like this.
START users=node(*)
WHERE (users.FirstName =~ '(?i)pal.*' OR users.LastName =~ '(?i)pal.*')
RETURN users;
It gives me just 2 nodes, but I want all node with is containing 'pal'
If I try like this
START users=node(*)
WHERE (users.FirstName =~ '(?i)*.pal.*' OR users.LastName =~ '(?i)*.pal.*')
RETURN users;
It is giving me following error.
"PatternSyntaxException"
Dangling meta character '' near index 4 (?i).ant. ^*
I have set example here for your ready reference.
Thanks.
The second query contains invalid regular expression syntax. I think you mean:
START users=node(*)
WHERE (users.FirstName =~ '(?i).*pal.*' OR users.LastName =~ '(?i).*pal.*')
RETURN users
Note the difference to the query in your post:
'(?i)*.pal.*' in your post, and
'(?i).*pal.*' in the above query
The asterisk * means the expression before me [the asterisk] may appear an arbitrary number of times, including zero. But (?i) is no regular expression but just a modifier to ignore the case of the actual expression. I think you meant .*. The regular expression . matches any character, the asterisk allows any character to appear an arbitrary number of times.
Thus, '(?i).*pal.*' says: [ignore case] <arbitrary number of any characters><the exact character sequence: "pal"><arbitrary number of any characters>
The above query returned four results for me:
users.FirstName | users.LastName
---------------------------------
sharma | shreepal
Rajpal | Yadav
Pal | Dharmesh
Manish | Pal
Which is what you wanted, if I understood your correctly.

Resources