For the URL based query in Socrata's SoQL is there a SQL equivalent of DISTINCT.
Thanks.
You can use $group to get something pretty similar. For example: https://data.agency.gov/resource/abcd-1234.json?$select=type&$group=type
I ran into the same use case. I just figured out that if you are using soda-java lib, you can build soqlquery like this:
new SoqlQueryBuilder()
.addSelectPhrase(field1)
.addGroupByPhrase(field1)
.build();
Related
I would like to filter fields returned via the ~:playableStreams decorator (cf. https://learn.microsoft.com/en-us/linkedin/shared/references/v2/digital-media-asset).
Is it possible? I tried but didn't succeed.
Also I can't find any documentation about the ~: syntax. What doesn't it mean?
Best regards.
I have this xquery as follows:
declare variable $i := doc()/some-element/modifier[empty(modifier-value)];
$i[1]/../..;
I need to run this query on Marklogic's Qconsole where we have 721170811 records. Since that is huge number of record, I am getting timeout error. Is there any way I can optimize this query to get the result?
P.S. I cannot request amdin to increase the timeout time.
Try creating an element range index (or a path range index if the target element is not unique) and using a cts:values() lexicon lookup.
That way, the request can read the values from the range index instead of having to read each document.
See:
http://docs.marklogic.com/guide/search-dev/lexicon
You could use xdmp:spawn, create a library when you will make the query, get the documents, iterate the result collecting 1000 documents per iteration and call another xdmp:spawn to process the information from that dataset, I would suggest summarize the result to return only the information you will need to don't crash the browser, at the end should look something like this:
xdmp:spawn("process.xqy")
into the library process.xqy
function local:start-process(){
let $docs := (....)
let $temp := for $x in $docs[$start to $end]
return local:process-dataset($temp) (: Could use spawn here too if you want :)
return xdmp:spawn("collect.xqy",$temp)
}
local:start-process()
compact-data function should create a file or a set of files with your data, this way the server will run all the process and in some minutes you will be available to see your data without problems.
You don't want to run something like doc() or xdmp:directory - just returns a result set that will kill you every time. You need to lower your result set by a lot.
A few thoughts:
You want to have as much done in MarkLogic's d-node, and the least work done in the e-node as possible. This is a way over-generalization, but for the most part I look at it like d-node stuff is data, indexes, lexicon work, etc. e-node stuff handles xQuery and such. So, in your example, you're definitely working out the e-node more than you need to.
You're going to want to use cts:search, as it uses indexes, not xPath to resolve your query. So, something like this:
declare variable $i := cts:search(fn:collection(),
cts:element-query(xs:QName("some-element"),
cts:element-value-query(xs:QName("modifier"), "", "exact")
)
)[1];
This will return document-node's, which it looks like what you were wanting with the $i[1]/../... This searches the xPath some-element for a modifier that is empty.
Please create element range index and attribute range index and use cts:search if you are familiar with marklogic it will be easy for you to write the query.
Here's the line that's making my query fail.
$query = $query->where('a.field LIKE :keyword OR LEFT(a.otherfield, 3) = LEFT(:keyword, 3)');
I get this error:
[Syntax Error] line 0, col 104: Error: Expected known function, got 'LEFT'
This SQL code works:
SELECT * FROM `table`
WHERE field LIKE 'searchterm'
OR LEFT(`otherfield`, 3) = LEFT('searchterm', 3)
Why does LEFT() return an error? Is there a different way to do it with query builder?
Try to look at this question. Otherwise, try the old school way! native-sql-with-doctrine.
#Houssem Zitoun's answer was good, and I'm marking it as the answer because it's relevant to my question. It's not the answer I used however
I already had the query written in sql that I wanted to use, so i decided to use a custom query with doctrine. It explains here how to do it. Symfony2 & Doctrine: Create custom SQL-Query
I am trying to run the below in ms access 2010 and not getting saying "Operation must use an updatable query"
Please some advice on how to solve this without creating a query or temp table.
UPDATE tmp SET non_null_cnt = (SELECT COUNT(id_sec) FROM ESG_Results WHERE asset4_id IS NOT NULL);
Thanks in advance.
Access is very finicky about subqueries in various contexts - I just try to avoid them, for the most part. As a workaround, you can try a domain count solution:
UPDATE tmp SET non_null_cnt = DCount("id_sec", "ESG_Results", "asset4_id IS NOT NULL");
See if that works for you. You could also write a quick function which uses a recordset solution if you want.
Is there some kind of SQL Statement that I can used to do a search on 1 Column in my table that is similar to what I am looking for.
Like if I am looking for something to do with a "Car" but I spell it as "Kar" it must return items of "car".
Or
If I am looking for "My Company" and I spell it as "MyCompany" it must still retun "My Company".
Select * from TableName where Column Like '%company%' will return "My Company" but I need more as the user will not always know how to spell. So I need something more advanced like some small Google App or something...
That feature is in the text services so if you build a full-text search index, you should be able to use the feature.
Have a look here:
http://msdn.microsoft.com/en-us/library/ms187384.aspx
http://msdn.microsoft.com/en-us/library/ms142571.aspx
This is quite an involved problem. The quick answer is to use the SQL Server soundex algorithm, but it's pretty hopeless. Try the suggestions on this SO answer. (Updated)
Read this blog post: http://googlesystem.blogspot.com/2007/04/simplified-version-of-googles-spell.html
This is something you could implement with SQL, but it's not a built in feature.
Another way to help you users find what they are looking for is to implement type-ahead on the search field. If the user type: "my" he will get "My Company" as a suggestion and likely go with that.
You can easily implement type ahead using jquery or other javascript libraries. Here's a list of type ahead plugins for jQuery: http://plugins.jquery.com/plugin-tags/typeahead
No. A full text index might get you closer, depending on your requirements (what exact features are you looking for?) One option would be roll you own .NET assembly with the desired features add it (CREATE ASSEMBLY) to sql server and use that to search.