This is the first time I'm working with RavenDB. I am not in a position to ask the creators of the code why they made certain decisions, so I am turning to internet strangers and hoping for some kindness. 😀
There are a number of search queries throughout the code and they all look like:
query.AndAlso().Search("Content", $"*searchExpression*");
The query is a RavenDB IDocumentQuery. The property Content is not defined on the document that is being searched for.
I think that this performs a search on all the properties in the document. Unfortunately I cannot find any documentation on this, so I am not sure how this impacts performance, security and injection attacks. I'm not even sure if this is actively discouraged.
Can somebody shine some light on this? Even if it's just the direction of my google searches as "ravendb search on content" does not return a lot of useful articles.
Edit: To clarify, I understand the syntax of the Search method. It takes the property to search and then an expression that is being searched for. But I have a document
public class Person {
public string FirstName {get; set;}
public string LastName {get; set;}
public DateTime DateOfBirth {get; set;}
}
The Search remains the same as above. There is no "Content" property in this Person document. Yet it does search on something, because I can see the list of documents get filtered. I just don't know what it's filtering on.
The first parameter to the .Search method is the property selector.
An expression marking the document field in which the terms should be looked for.
See method definition:
https://github.com/ravendb/ravendb/blob/904c34a939c35c6375726a57e6eb475086355fa7/src/Raven.Client/Documents/Session/IDocumentQueryBase.cs#L187
You can see a usage example in these tests:
https://github.com/ravendb/ravendb/blob/904c34a939c35c6375726a57e6eb475086355fa7/test/SlowTests/Issues/RavenDB_5669.cs#L17
https://github.com/ravendb/ravendb/blob/904c34a939c35c6375726a57e6eb475086355fa7/test/SlowTests/Issues/RavenDB_5669.cs#L45
Related
I followed the instructions here on establishing a new provider and generating custom URLs, and it works as expected. There doesn't seem to be a clear reference for what parameters can be utilized in the settings as the example given is very basic.
I want to use the category name of the post in the URL. I tried:
/[Category]/[UrlName]
but what I got in the frontend was:
http://localhost:60327/my-page/Telerik.OpenAccess.TrackedList%601[System.Guid]/my-post-name
I also tried
/[Category.Title]/[UrlName]
which just threw errors.
Anyone know how to do this, or better yet, a good reference for the parameters?
I don't think this is possible since the Category property is actually a collection (TrackedList).
In theory you would need one of the collection items, let's say the first one, and your URL expression would be /[Category[0].Title]/[UrlName], but this is currently not supported by the expression parser.
Also, the idea of making the URL dependent on a complex (related) field is not a good idea. If someone deletes that category, they will break all your blog post URLs.
I would suggest you to create a custom text field for the blog post item (ex: CategoryUrl) and then you should be able to set the URL format to /[CategoryUrl]/[UrlName]. Make sure CategoryUrl field is required.
I'm working on an UWP software which requires to manage a contacts list. Each contact must store at least one public key (hash) to identify themselves. I checked the API for UWP and it is quiet unclear for me how to do something like this.
for Windows8 phone there is StoredContact wich seems to be able to store custom fields. An example can be found at the page 16 of the presentation here : http://www.slideshare.net/WindowsPhoneRocks/16-interacting-with-user-data-contacts-and-appointments
for UWP, I tried first to add StoredContact. But I have no access to Windows::Phone::PersonalInformation (see namespace here : https://msdn.microsoft.com/en-us/library/windows/apps/jj207745.aspx). (n.b. I'm not targeting phone device).
then I tried to add custom field with Contact (https://msdn.microsoft.com/library/windows/apps/br224849) but at this point I have no idea how to. Since Windows::ApplicationModel::Contacts is sealed I cannot try to create a child class and adding a property HashKey.
Technicaly I could have a class HashKey wich is something like Windows::ApplicationModel::Contacts::ContactPhone.
If it's not possible to store custome field I really need to know it, because it's a critical issue for me.
msdn version : https://social.msdn.microsoft.com/Forums/windowsapps/en-US/d3886f74-3579-43b9-9870-a465c6ff51ea/creating-a-contact-with-custom-field-?forum=wpdevelop#d3886f74-3579-43b9-9870-a465c6ff51ea
I replied your same question in MSDN, please see: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/d3886f74-3579-43b9-9870-a465c6ff51ea/creating-a-contact-with-custom-field-?forum=wpdevelop.
Contact object is designed to not allowed add a new one but you can change the exist field.
Since you didn't mentioned you developing with C++ ,so I gave a C# code. Here is the simple C++ code sample:
ContactPhone^ phone1 =ref new ContactPhone();
phone1->Number = "secrectword";
phone1->Description = "password";
contact1->Phones->Append(phone1);
I am using graph search api to search a public post posted for me on my wall. Example:
https://graph.facebook.com/search?q=awstdw&type=post
My post contains the keyword "awstdw".
The above search not returning my post and this is a public post.
What's the problem?
You might need to wait for Facebook to update the cache on this term. It would show nothing if you happened to search for the term before posing something that contained it.
If you try: https://graph.facebook.com/search?q=facebook&type=post you will that it does work. Try creating a new post with a different keyword, and then try searching for it, e.g.
https://graph.facebook.com/search?q=asdasd&type=post
I'm trying to wrap my head around designing a simple Wiki style app. In a traditional wiki, say wikipedia, are 'links' referenced in any kind of backend/complex way? Ie HABTM... or are links simply links?
I'm trying to decide myself what to do, a bit different but similar. I have pages written by individuals which they can attribute to themselves or credit a.. say a famous author. Should I save this attribution as merely a tag? The tag would create a reference to the famous person, which may or may not exist, but could also be created, but nothing more than a link. OR, do I dive deep and create a real data relationship (HABTM) ?
Thoughts?
A SQL-style Has And Belongs To Many mapping table is never necessary in Mongo.
If you'd like to provide, for example, a "what links here" view for a page, then I would do something like this for each page in your Wiki. I'll give an example of a page about pandas:
{
_id: "Panda",
text: "Page's contents go here",
links: ["Raccoon", "Weasel"]
}
You're using the page's title as its _id. To find titles of pages that link to "Raccoon", you can query like:
db.pages.find({"links": "Raccoon"})
Obviously, you should make an index on "links".
I'm writing a REST API and i want some feedback.
I will have one resource called Items. I want it to be accessed publically or it can be privated (only the user can see it). My First idea was to put a URL to public items like
/Root/Items where the public items will live, and other URL like /Root/User/Items where private items will live. An Item can be linked to another user so it will have permission to update it. Something like /Root/User/Operator/Items .... but then i realize i'm creating too many addresses.
I dont like the idea to put all the items inside de /Root/Items url because each user will have a different output. And putting it only inside the /Root/user/Items will be not possible to list all the public items (that can belongs to any user).
Any idea how can i design that?
In RESTful architectures every "thing" should have one identifier which is a URI if you use HTTP as I expect. In your case, every item should have exactly one URI.
My First idea was to put a URL to public items like /Root/Items where the public items will live, and other URL like /Root/User/Items where private items will live.
I assume that you are not only talking about collection resources which will return a collection of items. I assume that you will have also single item resources. A URI of a single item could be /Root/Items/42 or /Root/User/Items/23 in your scheme.
You can use different URI schemes for public and private items if it helps you doing the authorization needed. But anyway URIs did not matter in REST. URIs should be always regarded opaque. If you use that different schemes for public and private items, you have to ensure that a public item can never become private and the other way around. If so the URI of a item would change and that's the same as if you would change the primary key of a row in a database. Identifiers should not change. What you are doing if you are using different URI schemes for public and private items is encoding the privacy level of your items into there identifiers. If your problem domain allows this, it is ok.
An Item can be linked to another user so it will have permission to update it. Something like /Root/User/Operator/Items .... but then i realize i'm creating too many addresses.
This sounds like as you want to change the privacy level of an item. As I said before, one item should have exactly one URI which never changes. If you are talking about collection resources, your scheme might be. I'm not sure what you mean here.
At the end: What you need is Authentication and Authorization. You need to return a 403 Forbidden if a user wants to access a private item of another user regardless of its URI.