Passing an arguement in a label in a query written in SPARQL - sparql

I am trying to query Wikidata for the uris of entities, given their label. I am passing the label as a string argument in the query like this:
?uri skos:altLabel|skos:prefLabel|rdfs:label \" """+argument+"""\"#en .
However, due to the space that I have to leave between " and """+argument+""" my query does not find any results because the label doesn't match any existing one. If I don't use a space, then all four " stick together and the syntax of the query gets ruined.
Does anybody have any solutions that will allow me to find results for my query?

Related

Filter for "contains text" with OR or CASE to allow multiple options in NetSuite. Custom field: Keyword Match option seems available

NetSuite formula(text) problem.
I have a specific search I need to power up but I could also really use this for general use across a few types of reporting.
We use a lot of custom body fields which do not seem to have access to the Keyword Match option in the dropdown system or I would be using commas left and right.
I need to search a single custom field for multiple possible answers.
I was thinking maybe a CASE WHEN formula but I don't have an else.
Lets call the field states. I want this report to only return rows of records where there are the following 5 states in the custom body field "Shipping State". it isn't allowing keyword match. I only want to see transactions with Michigan, New Jersey and Floria (this is hypothetical) so I want just to put a filter in up front to pair down the results.
CASE WHEN {custbody.shippingstate} IS 'Michigan' ...
Can I use an OR construct here? and do I need an else?
I tried using coalesce but I don't think I had the syntax around the coalese right.
Any help for a formula newbie appreciated.
Try the following as a formula text result column in a NetSuite saved search.
CASE WHEN LOWER({custbody.shippingstate}) LIKE '%michigan%'
OR LOWER({custbody.shippingstate}) LIKE '%jersey%'
OR LOWER({custbody.shippingstate}) LIKE '%florida%'
THEN 'Y' END
LIKE conditions are case sensitive, so that's why I incorporated the LOWER() method. Reminder in NetSuite "%" matches any string of any length (including zero length, and "_" matches a single character. If this works as a results column you can add the formula text as a criteria to filter results.

How to pass arguments from an Access form to SQL Query with "IN" clause?

I'm having trouble getting this query to display any results.
SELECT Evaluation_Table.*
FROM Evaluation_Table
WHERE (Evaluation_Table.Test_ID
In ([Forms]![Test Data]![Group_Test_IDs]));
The control, [Group_Test_IDs] is a textbox that contains a string of IDs. For example it just contains numbers separated by commas: 1,2,3,4,5.
While debugging, If I changed the query to look like this, it properly returns records:
SELECT Evaluation_Table.*
FROM Evaluation_Table
WHERE (Evaluation_Table.Test_ID
In (1,2,3,4,5));
I can't seem to find the proper syntax. SQL in Access can sometimes be weird.
I can't seem to find the proper syntax.
That's because there is none.
The IN selection cannot be dynamic; your only option is to rewrite the SQL via VBA.

Examine lucene.net custom query after analyzer tokenizes

I'm using Examine in Umbraco to query Lucene index of content nodes. I have a field "completeNodeText" that is the concatenation of all the node properties (to keep things simple and not search across multiple fields).
I'm accepting user-submitted search terms. When the search term is multiple words (ie, "firstterm secondterm"), I want the resulting query to be an OR query: Bring me back results where fullNodeText is firstterm OR secondterm.
I want:
{+completeNodeText:"firstterm ? secondterm"}
but instead, I'm getting:
{+completeNodeText:"firstterm secondterm"}
If I search for "firstterm OR secondterm" instead of "firstterm secondterm", then the generated query is correctly: {+completeNodeText:"firstterm ? secondterm"}
I'm using the following API calls:
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
var query = searchCriteria.Field("completeNodeText", term).Compile();
Is there an easy way to force Examine to generate this "OR" query? Or do I have to manually construct the raw query by calling the StandardAnalyzer to tokenize the user input and concatenating together a query by iterating through the tokens? And bypassing the entire Examine fluent query API?
I don't think that question mark means what you think it means.
It looks like you are generating a PhraseQuery, but you want two disjoint TermQueries. In Lucene query syntax, a phrase query is enclosed in quotes.
"firstterm secondterm"
A phrase query is looking for precisely that phrase, with the two terms appearing consecutively, and in order. Placing an OR within a phrase query does not perform any sort of boolean logic, but rather treats it as the word "OR". The question mark is a placeholder using in PhraseQuery.toString() to represent a removed stop word (See #Lucene-1396). You are still performing a phrasequery, but now it is expecting a three word phrase firstterm, followed by a removed stop word, followed by secondterm
To simply search for two separate terms, get rid of the quotes.
firstterm secondterm
Will search for any document with either of those terms (with higher score given to documents with both).

Why queryString would not give any results even added keyword analyzed fields into query

i have a doubt that how query is search into documents.
When i searched with exact query "what is 1234?" against the keyword analyzed field,i could not get any results.
but if i searched "what" against snowball/standard analyzed field then i got some results and i also tried another way to escape space into the query like "what\ is\ 1234?", it also gave some results.
By default what analyzer the query_string will use, whether it will convert user query using any analyzer or it will use what users gave?
please find my gist here: https://gist.github.com/kirubar/6369034
The reason the query string "what is 1234?" fails to find results isn't the Analyzer, it's the QueryParser.
query_string uses Lucene query syntax. The query parser will interpret that query as three separate queries. That is to say
"query" : "what is 1234?"
Is the equvalent of:
"query" : "what OR is OR 1234?"
If you want to perform a phrase query, it will need to be enclosed on quotes, something like (I beleive you will also need to set the analyzer to a KeywordAnalyzer, so the phrase won't be tokenized, once again preventing matching):
"analyzer" : "keyword",
"query" : "\"what is 1234?\""
Or, better yet, don't even use a query_string query. Instead, use a term query, particularly when querying on a keyword field, like:
"term" : { "message_keyword" : "what is 1234?" }

SQL Server CONTAINS with digits gives no results

I have a database table which is full-text indexed and i use the CONTAINS-function to perform a search-query on it.
When I do:
SELECT * FROM Plants WHERE CONTAINS(Plants.Description, '"Plant*" AND "one*"');
I get back all correct results matching a description with the words "Plant" and "one".
Some plant are named like "Plant 1", "Plant 2" etc. and this is the problem.
When i do this, i get no results:
SELECT * FROM Plants WHERE CONTAINS(Plants.Description, '"Plant*" AND "1*"');
Anyone know why?
There is a list of commonly-used words that are not indexed in a keyword search, such as "and" and "the".
I believe the text "1" also appears in that list. Therefore it doesn't appear in the index, and can't be found with the CONTAINS clause.
If I recall correctly, there is an admin interface to allow you to edit that list of common words. I tried editing it once, a few years ago, and I recall having trouble telling the difference after I did.
Daan is correct. you need another * before the 1. Placing wildcards either side of a search term searches the entire string for the search term regardless of its position.