I have no problem querying RavenDB from code, but sometimes a quick lookup directly to RavenDB would be nice. Unfortunately, I cannot figure it out despite tips that it uses Lucene syntax.
For example, I have a RegionLocation document:
{
"RegionId": 804291854,
"Name": "Miami",
"Description": null,
"DbRowStatus": 0,
"CreatedBy": "Zorro",
"UpdatedBy": null,
"DeletedBy": null,
"CreatedOn": "2013-06-05T18:31:37.4332753",
}
I haven't had any luck with quering it. RegionLocation.Name: M* returns no results.
Any idea what I am doing wrong?
Assuming you already have an index that has the name mapped, or you are building a new dynamic index against the RegionLocation documents, then the syntax for your query would just be:
Name: M*
I agree that the documentation could be better - especially the in-application help. But you can find most of what you need to know here.
UPDATE
This was raised as Issue #1250, and closed in RavenDB 2.5.2750. The studio now includes easily accessible help:
The popup shows when you hover over the (i) icon, and the "Query syntax online" link points at the relevant Lucene documentation.
Related
Is it possible to display every built-in function (like LEFT, SIN, IIF etc.) with a query?
Documentation or syntax highlighting definition from official tool:
Azure Data Studio - syntax support
{
"match": "(?i)\\b(avg|checksum_agg|count|count_big|grouping|grouping_id|max|min|sum|stdev|stdevp|var|varp)\\b",
"name": "support.function.aggregate.sql"
},
{
"match": "(?i)\\b(cast|convert|parse|try_cast|try_convert|try_parse)\\b",
"name": "support.function.conversion.sql"
}, ...
Searching for: "name": "support.function
Idea - Not tested: Maybe it is possible to extract that data from system database - Resource
Resource Database
The Resource database is a read-only database that contains all the system objects that are included with SQL Server.
No, the functions documentation is your best alternative. It gives a structured overview of all supported built-in functions.
Using any decent IDE will provide some highlighting and auto-completion features for function names.
First off. I am having trouble finding documentation for how to use ravendb with lucene. I can't seem to find documentation to help me query ravendb in the raven studio. Can anyone point men int he right direction?
So if I have the following document:
{
"Name": "My Name",
"object": {
"ObjectName": "Name of an object"
},
"array": [
{
"first": "first element"
},
{
"second": "second element"
}
]
}
How can I query ravendb to find all documents that have a "first element" string for the "first" key?
If I do array.count: 2. That will return all documents that where array has a length of 2. However if I want to find arrays where the array has greater than say 4 elements, array.count > 4 does not work.
Any advice would be much appreciated.
Again, can you point me to this elusive documentation. I must be searching for the wrong thing.
Cheers
The query syntax is documented here:
https://ravendb.net/docs/article-page/3.5/csharp/indexes/querying/full-query-syntax
The query you want is:
array,first: "first element"
The comma operation in RavenDB 3.5 is used to nest into an array.
For range queries, you'll need:
array.Count_Range: [Ix4 TO *]
Using Azure Search REST API v2016-09-01, the following query find the expected document:
?queryType=full&search=id:3119443 AND name:du*
{
"value": [
{
"#search.score": 4.425995,
"id": "3119443",
"name": "dupond"
}
]
}
Whereas the following broader query (searching d* instead of du*) does not find the same document:
?queryType=full&search=id:3119443 AND name:d*
{
"value": []
}
The name field uses a custom analyzer with the Whitespace tokenizer and the WordDelimiterTokenFilter, AsciiFoldingTokenFilter and Lowercase token filters.
Most of the indexed documents are correctly found when searching their first name letter.
The issue is 100% reproducible on those specific documents, for which I don't find anything special.
The Search Service is a "Standard" tier (1 replica, 1 partition, 1 search unit), with the index containing 3,000,000+ documents.
Thank you.
Thanks for reporting the issue. As commented, this is a regression introduced in a recent change. The bug has been fixed. Thanks.
Discussion at work has become quite divisive.
I request a collection from /books
{
"offset": 0,
"limit": 10,
"total": 3,
"results": [
{
"id" : 1,
"title" : "Book 1"
},
{
"id" : 2,
"title" : "Book 2"
},
{
"id" : 3,
"title" : "Book 3"
}
]
}
This is paginated.
Now if I request to books/<id> for a specific resource, should this be wrapped in a pagination results block too?
Some think that everything should be paginated but some think that a request to a unique item should respond with that and just that. So...
{
"id" : 1,
"title" : "Book 1"
}
This makes the most sense to me, as you're not requesting a collection you're requesting that specific item, why would a single resource need to be paginated?
I can understand this for the sake of consistency for the clients but I just want other opinions as I understand there's no right implementation of this obviously.
Thanks in advance,
Looking forward to everyone's points :)
We've all been there :), thanks to standards, things are much more consistent and cleaner of course. i personally apply the jsonapi.org v1.0 standard, which helped me a lot to make my restful services "standardized".
to answer your question, i think, if you are requesting one entity, well.. wrapping it with pagination is an extra work and you will not use it. the way i see it, is that you asked the restfull server to return only one entity, so why returning the pages, you dont need them, you requested one entity, you are aware of it! you should handle it. programming logic, only return/use what you need, unless you have an exception. ( and that another issue, re-factor your app architecture ).
hope this helps :)
I second the answer. Don't return the pagination for the single entity. The structure can imply as much meaning as the result itself. It may be important to note that the list itself returned only a single result - hence pagination vs. requesting a single result and getting exactly that one back.
Too many times I have seen in the past where bugs crop up where it's difficult to discern because of these 'optimizations'. Stick to your strong API definitions and it will pay dividends in not wasting hours debugging.
I am new to Freebase and I have been trying to find relationships between 2 nodes without success.
For example, I want to find if there is link between Lewis Hamilton(/en/lewis_hamilton) and Formula One(/en/formula_one), which there is in real life, but I can't seem to find it.
I have tried the following MQL codes, alternating IDs as well :
1)
[{
"type" : "/type/link",
"source" : { "id" : "/en/lewis_hamilton" },
"master_property" : null,
"target" : { "id" : "/en/formula_one" },
"target_value" : null
}]
2)
{
"id":"/en/lewis_hamilton",
"/type/reflect/any_master":[{
"link":null,
"name":null
}],
"/type/reflect/any_reverse":[{
"link":null,
"name":null
}],
"/type/reflect/any_value":[{
"link":null,
"value":null
}]
}
I'm also not able to use a couple of their apps that could do this because it returns "user rate limit exceeded" every time. Apps are:
http://between.freebaseapps.com
http://shortestpath.freebaseapps.com
Do you guys have any suggestions?
The queries that you gave are correct except that they only look at relationships that are one link apart. Surprisingly there isn't a path from Lewis Hamilton to Formula One in Freebase right now. If there was it might look something like this:
/en/lewis_hamilton → /type/object/type → /base/formula1/formula_1_driver
/base/formula1/formula_1_driver → /type/type/domain → /base/formula1
/base/formula1 → /freebase/domain_profile/equivalent_topic → /en/formula_one
Freebase doesn't support recursive queries so there's no good way to find these multi-link paths between topics. The apps that you tried simulate recursion by generating queries with increasingly nested subqueries. Unfortunately they are out of date and missing the proper API keys to run properly right now. Here's what those nested queries look like:
{
"id": "/en/lewis_hamilton",
"name": null,
"/type/reflect/any_master": [{
"link": {
"master_property": null,
"target": {
"id": null,
"name": null,
"/type/reflect/any_master": [{
"link": {
"master_property": null,
"target": {
"id": "//base/formula1",
"name": null
}
},
"name": null
}]
}
},
"name": null
}]
}
These sorts of queries can take a long time to run and are probably better if run locally over the Freebase data dumps.
Freebase is returning nothing but 503s right now, so it's a little difficult to experiment, but
All apps on Freebaseapps are open source, so looking at the sources for the apps you found should give you some good hints. The app directory is at https://www.freebase.com/apps (but isn't rendering right now)
All apps on Freebaseapps can be cloned with a single click. Pretty much every app written on that infrastructure stopped working when Google switched to the new API and the developers are unlikely to fix them if they haven't been looked at in years, but you can probably get the ones of interest working by a) cloning them, b) registering for an API key and c) adding that API key to cloned app.