asp.net-mvc,pagination,ravendb
Okay so basically what you will need to do is calculate the number of results that were in the previous pages and the number of results that are in the current page. Below is a quick example app to give you an idea of how to do it. One caveat,...
You have a couple of options here. You could store both the CategoryId and the CategoryName on the Item entity. This will of course lead to duplicated data (if you still need to store the Category entity), but "storage is cheap" is a popular term these days.The downside of this...
You can use the streaming API for that.
There is no way to know, nothing in RavenDB really cares if the document exists already or being created.
In RavenDB 3.0 they added a Java client as well. I haven't tried it myself, but you can read about it here: http://ayende.com/blog/168354/what-is-new-in-ravendb-3-0-jvm-client-api In that blog post Ayende also mentions: RavenDB has always been accessible from other platforms. We have users using RavenDB from Python and Node.JS, we also have...
The problem is that you referencing RavenDB.Client in the top level dependencies node in project.json. That means that those dependencies are applicable to both Desktop CLR (aspnet50) and CoreCLR (aspnetcore50). When you build an ASPNET 5 project, all configurations are built, not just the "active" one. Mostly sure RavenDB.Client works...
exception,ravendb,ravendb-http
That exception is from the watch that we use for the bulk insert. When it is done, we close the watch, and the exception is thrown. It is handled internally, and shouldn't have any affect on your application
You can do it using: http://localhost:8080/databases/{database name}/indexes/dynamic/CollectionName ...
You mentioned that you tried casting the string to object. I tried it using :> obj and it does work. Here is my working query: let expr = <@ Func<MyType,_>(fun x -> x.Text :> obj ) @> |> LeafExpressionConverter.QuotationToExpression |> unbox<Linq.Expressions.Expression<Func<MyType,_>>> let events = session.Query<MyType>() .Search(expr, "Liv*", decimal 1, SearchOptions.Or,...
The best I could come up so far is: Map = boards => from board in boards select new { Users = new object[] { board.CreatedBy, board.Settings.Admins, board.Settings.Members } }; Reduce = results => from r in results group r by "all" into g select new { Users = g.SelectMany(x...
There is no other way to get the terms of an index. To get the terms the only function that the client api offers is documented here. So if you have to get the terms filtered by some property value you must move the where clause to the index definition....
c#,domain-driven-design,ravendb,cqrs
You can use RavenDB in the normal way - just load and save items through the session: public class RavenEventStorage : IEventStorage { private IDocumentStore store; public RavenEventStorage(IDocumentStore store) { this.store = store; } public IEnumerable<Event> GetEvents(Guid aggregateId) { using(var session = store.OpenSession()) { BaseMemento memento = session.Load<BaseMemento>(aggregateId); // Its...
This would require to go over all the data in the db. Instead, do two queries. One to get the first one equal or less than the date. One to get the first one equal or greater than the date. Then pick the closest....
You need to just remove the document value. var artist = Session.Load<AllArtists>("artists/1"); artists.Albums.RemoveAt(3); Session.SaveChages(); ...
That URL would address the system database. I assume you are using a named database. Try http://localhost:9999/databases/{DbName}/docs/locations/1...
With thanks to Ayende Rahien for support provided offline, it turned out this issue is actually due to a feature of IIS itself: Windows XP SP2 and Windows Server 2003 SP1 include a loopback check security feature that is designed to help prevent reflection attacks on your computer. Therefore, authentication...
One option (albeit possibly inefficient) is that you can always pull the query into memory and then perform .All (or any other Linq method) because the records are already loaded into the application space. To do this in most cases, you just add .AsEnumerable() on your IQueyable object. Because extension...
Finally i got solution... Bellow is the Map-Reduce function,in which i have used LoadDocument<> for selecting data from ImportTiming Document. public class IdxJoinBetweenCollections : AbstractIndexCreationTask<Ticket,JoinBetweenCollections.ResultClass> { public IdxJoinBetweenCollections() { Map = docs => from doc in docs let TimeDoc = LoadDocument<ImportTiming>("ImportTiming/" + doc.TicketID) select new { ID = doc.TicketID, Total...
Just like any other service, you can use the services management console to start, stop, and configure startup preferences. Run services.msc or search for "Services" from your start screen....
You can manipulate the index query to filter out all but "current" version. See: http://www.mostlylucid.co.uk/archive/2010/07/12/handy-indexes-for-versioning-with-ravendb.aspx
Using information from here I changed the map to the following which solves the problem. from doc in docs from text1 in ((IEnumerable<dynamic>)doc.Texts1) from text2 in ((IEnumerable<dynamic>)doc.Texts2) from text3 in ((IEnumerable<dynamic>)doc.Texts3) select new { Text1 = text1, Text2 = text2, Text3 = text3 } Unfortunately I don't understand why this...
c#,search,escaping,ravendb,iqueryable
Ok, it turned out it was pretty easy. We were using a base Tokenizer in our Analyser, which filters out all special characters and characters with a length of 1. When we replaced public override TokenStream TokenStream(string fieldName, TextReader reader) { return new LowerCaseFilter(new ASCIIFoldingFilter(base.TokenStream(fieldName, reader))); } in our AsciiFoldingAnalyser...
I ended up adding two fields to an index, both based on SomeText. One analyzed using the StandardAnalyzer and the other using the LowerCaseKeywordAnalyzer. This allowed me to do starts with searches using the field indexed by the LowerCaseKeywordAnalyzer. Using the field indexed by the StandardAnalyzer would have generated a...
Have you tried using the .Skip() method instead? MyDoc nthValue = session.Query<MyDoc, MyDoc_Index>().Skip(nStep-1).FirstOrDefault(); ...
asp.net-web-api,ninject,ravendb,simple-injector,membershipreboot
Simple Injector forces you to let your components to have one single public constructor, because having multiple injection constructors is an anti-pattern. In case the UserAccountService is part of your code base, you should remove the constructor that should not be used for auto-wiring. In case the UserAccountService is part...
Yes, you can just use it like that. Note that RavenDB comes with clients for both .NET and Java.
You need Intersect when using multiple where clauses. To combine Where and Search, you have to pass SearchOptions.And to Search: using (var db = _documentStore.OpenSession()) { RavenQueryStatistics stats; var query = db.Query<Club>() .Customize(_ => _.WaitForNonStaleResultsAsOfLastWrite()) .Statistics(out stats) .Where(club => club.Type == "Amateur") .Search( club => club.Name, "Foo*", escapeQueryOptions: EscapeQueryOptions.AllowPostfixWildcard, options:SearchOptions.And);...
linq,ravendb,lucene.net,contains
Not sure this is what you're looking for, but this is using ravendb (build 3548) DocumentQuery wich takes a lucene query in the where statement: using (var session = _documentStore.OpenSession()) { var result = session.Advanced .DocumentQuery<Events>() .Where("Details: *test*") .ToList(); } http://ravendb.net/docs/article-page/2.0/csharp/client-api/querying/query-and-lucene-query Edit: This might not be very effective in terms...
You need to Parse the JSON into an object and then hand it over to Raven DB. Strings are treated as strings. Use JSON.NET library to parse it into Anonymous objects. Change your Info property to type of object. Then Assign the anonymous object to the Info property.
I didn't understand what was meant by trying to use AsDocument and my attempts at using it resulted in ugly code that didn't work, so I gave that up and tried to come up with another idea. It turns out that the <T> in the AbstractTransformerCreationTask doesn't have to align...
You asked RavenDB to fetch the property from the index, so you need to actually specify the property. Use the following index: public class TestIndex : AbstractIndexCreationTask<CardApplication> { public TestIndex() { Map = apps => from app in apps select new { State = app.State, IdentityDetails_Applicant_FirstName = app IdentityDetails.Applicant.FirstName}; Sort(c...
indexing,ravendb,event-sourcing
You can do that using Scripted Index Results. See the docs http://ravendb.net/docs/article-page/2.5/csharp/server/extending/bundles/scripted-index-results
The key was in the Indexing value for the field, it must be set to Default in order for the range field to be set up correctly for integer sorting. ...
You can do it the other way, keep track of the comments on the user, so you can show the comments they liked.
You would need to use the LuceneQuery to manually set the property name for the query.
Use something like MD5 or SHA1 for consistent hashing. But be aware of things like case sensitivity for this if you care about it.
Update the NServiceBus package to the latest (5.2.0) and this should solve the issue
ConcurrencyException means that on a single server, you have two writes to the same document at the same instant. That lead to: One write is accepted. One write is rejected (with concurrency exception). ...
If a product can only have one category then it would something like this: products = from p in session.Query<Product>() where p.Category.In(new[] { 1,2,3 }) select p; If multiple categories for a product the following should work: products = from p in session.Query<Product>() where p.Categories.Any(new[] { 1,2,3 }) select p;...
I found the solution, it's due to the choice of the analyzer for the index : http://ravendb.net/docs/article-page/2.5/Csharp/client-api/querying/static-indexes/configuring-index-options I choose the "KeywordAnalyzer"....
RavenDB does support transactions for patches, as long as you are patching by id. If you are patching by query, the operation is handled as a transaction for each individual document, but not globally. Calling LoadDocument in a patch will result in all documents modified by a patch sharing the...
If you need it that way, you can do: from doc in docs from text in doc.Tests select new { Text = text } Note that this is a fan-out index, and if you have a lot of texts per document, that require paying attention to the resources required....
The structure for PATCH is : [ { Method: 'PATCH', Key: 'users/1', Patches: [{ Type: 'Set', Name:'username', Value: 'new-username' }] }, ... ] The full structure can be see here: https://github.com/ayende/ravendb/blob/master/Raven.Abstractions/Commands/PatchCommandData.cs#L72...
The documentation says explicitly for unbound results: Important side notes: the index already exists. Creation of a index won't occur and the query error with an IndexDoesNotExistsException exception. And that's what your exception is saying. You have to create a static index for streaming results....
Change the index to be: from pupil in docs.Pupils from year in Enumerable.Select(Enumerable.Range(pupil.BirthAcademicYear, 12), (Func<int,object>)(u=> u)) select new { pupil.Upn, year } ...
You are using a 3.0 client to talk to a 2.x server, that is not supported.
You can use lazy loading: Lazy<One> oneLazy = session.Advanced.Lazily.Load<One>("ones/1"); Lazy<Two> twoLazy = session.Advanced.Lazily.Load<Two("twos/2"); var numbers = new FeedMeDocs() { one = oneLazy.Result, two = twoLazy.Result }; On the first access of one of the Lazy<>'s Result the session will query the server for the collected Load's....
Sharding is designed to be independent, but in order to create consistent ids, we need to be able to create them from a consistent store. Because of that, we separate the notion of splitting data to multiple nodes and HA. The typical scenario is that the metadata shard is independent,...
The customary way to do something like this is by using an index (i.e. a map - reduce index). I haven't thoroughly thought this though, so there may be easier ways to achieve this than using a multi map, but I think you can do the following: public class CategoryUsageCount...
Add Where condition after Select to filter the size: Map = listings => listings .Select(listing => new { category = listing.Category, make = listing.Make, size = listing.Size // Size may sometimes be NULL }).Where(e => e.Size != null); ...
It's all just HTTP, so you can access the studio from another computer. You may need to update your Windows Firewall settings to allow access.
Finally, the high response time is due to the size of packets sent in the network (limited to 1514 bytes). We spend many time to assemble all the packets.
You can try the index replication bundle and compile that on 3.0
database,mongodb,nosql,ravendb
Your document could look something like this in MongoDB: { person_id:PersonId, name: PersonName, addresses:[{ id:AddressId1, street:AddressText1 }, { id:AddressId2, street:AddressText2 }, ... { id:AddressIdn, street:AddressTextn }] } Then, we could update the second address this way: db.collection.update({person_id:PersonId,"addresses.id":AddressId2},{$set:{"addresses.$.street":NewAddress}}) See here for additional detail:...
Set EnlistInDistributedTransactions = false on the document store, and it will work for you
As far as I understand you do not need the blogs in your index but their languages: AddMap<Post>((posts) => from post in posts select new { UserId = post.AuthorId, Count = 1, Language = LoadDocument<Blog>(post.BlogId).Language }); and then reduce by UserId and Language: Reduce = results => from result in...
Here's one way to do a pivot in Linq: var pivot = data .GroupBy(d => new {d.Name, d.Year}) .Select(g => new { Name = g.Key.Name, Year = g.Key.Year, East = g.Where(c => c.State == "East").Sum(c => c.Total), West = g.Where(c => c.State == "West").Sum(c => c.Total), North = g.Where(c =>...
testing,transactions,nosql,nunit,ravendb
I also posted this question in https://groups.google.com/forum/?hl=sv#!topic/ravendb/2fHg48KkuZM And ayende answered it. The solution is to use esent to run the test and not voron. I added this setting: documentStore.Configuration.DefaultStorageTypeName = "esent"; ...
The easiest way would be to read it all from the single server and write it to the sharded store, yes. Alternatively, you can manually move the data and make sure that the sharding strategy you use handle it, but that is more complex....
The .Where(...) in your case is using the standard where in "System.Linq" namespace but in order to use .TransformWith<>() you need to use the .Where(...) extension in "Raven.Client.Linq" namespace. Make sure you have: using Raven.Client.Linq; in your code....
In Raven 2.5 there are no simple solutions for this problem and the only way to solve this is by creating a separate query that returns all distinct id's within that query and then counting the results. This issue is solved in raven 3.0 since there is a replacement on...
You can use set based operation. The following code will query specific index and delete everything matching the query var operation = store.DatabaseCommands.DeleteByIndex("Index Name", new IndexQuery { Query = "Lucene query of stuff to delete" }, options: null); for example, the following code will delete all documents from a document...
LoadDocument is cached, so calling it once or multiple times for the same document doesn't really matter.
You can use the output() method to send values back to the user.
Yes, it will be returned in the same order that you gave it.
According to the documentation, By default, the Versioning bundle will track history for all documents and never purge old revisions. It turns out that for the embedded database, the versioning configuration document must be added. using (var session = Store.OpenSession()) { session.Store(new { Exclude = false, Id = "Raven/Versioning/DefaultConfiguration" });...
Idsa, You can resolve that without patching by setting UseOptimisticConcurrency=true; on the session, which will cause a ConcurrencyException to be thrown. With Patching, we'll make sure that the patch is always running on a consistent view of the document, and it will only be applied if there has been no...
ravendb,geospatial,spatial-query
You cannot ask this question as stated. Instead of storing a radius, store a circle shape from the location, then you can call intersect on that.
Not sure about Lucene, but you can do what you ask for with a MultiMap index: public class CustomerAndBusiness_ByName : AbstractMultiMapIndexCreationTask<CustomerBusiness> { public CustomerAndBusiness_ByName() { AddMap<Business>(businesses => from business in businesses select new { business.Id, business.Name }); AddMap<Customer>(customers => from customer in customers select new { customer.Id, customer.Name }); Index(x...
In the constructor for NewDocumentStore pass in the configureStore parameter. This is an Action that takes the EmbeddableDocumentStore as its parameter. Within that action you can set different parts of the Configuration, including the AllowOn32Bits property. public void ConfigureTestStore(EmbeddableDocumentStore documentStore) { documentStore.Configuration.Storage.Voron.AllowOn32Bits = true; } Then pass this as the...
indexing,ravendb,eventual-consistency
That is by design, whenever you modify a document, all documents are stale until they can verify that this document isn't related to them.
You are looking for: DestinationSyncResult[] syncResults = await store.AsyncFilesCommands.Synchronization.SynchronizeAsync(); This will force your server to push all changes to destinations and return all the details about processed files and errors if happened any. Investigate also more methods exposed by IAsyncFilesSynchronizationCommands: store.AsyncFilesCommands.Synchronization.XXXXX You can also use the Changes API mechanism to...
Assigning the quote object to temp will not allow you to use session.SaveChanges() without doing another session.Store(quote); So either make the changes on the quote object itself or call session.Store(quote); again. More Detail: When you load an object from Raven it is actually a proxy class with tracking enabled. If...
c#,search,full-text-search,ravendb,iqueryable
You really don't need to bother. Unless I am having a serious brainfart, it would not change your result because the OR condition will always be matched by the preceding chain of ANDs....
dependency-injection,ravendb,asp.net-5
You can actually access RequestServices off of the HttpContext to get scoped instances. It's kind of backwards, and really will depend on Microsoft.AspNet to do it, but it will work for your situation; interestingly, IHttpContextAccessor is a singleton, too, though it gives you a scoped value. // injected: IHttpContextAccessor httpContextAccessor;...
By default RavenDB uses the Id property as the identity of the document, and complex types are not supported (as far as I know). I recommend reading Working with document identifiers. In general you can change the name of the identity property in Conventions.FindIdentityProperty, but I recommend to change the...
asp.net-mvc-4,ravendb,mvcjqgrid
You need to recover the embedded raven database. More information how to do that: https://groups.google.com/forum/#!topic/ravendb/eKUYf2cHUkQ I think we accidentally committed a corrupted ravendb in the repository. ...
There is a known issue in 3599 regarding dates queries, we've issued a quick fix in an unstable, and will soon have an update.
Change your query to be: var luceneQuery = Session.Advanced.LuceneQuery<Test.ReduceResult>("Raven/DocumentsByEntityName") .WhereEquals("Tag", "Customers"); This will give you all customers....
That information is available in the Raven/Sources/URL document, and you can read it like any other document.
I removed my earlier answer as it proved to be incorrect. In this case you can actually use a MultiMap/Reduce index to solve your problem. Try using the following index: public class Category_Items : AbstractMultiMapIndexCreationTask<Category_Items.ReduceResult> { public class ReduceResult { public string CategoryId { get; set; } public int Count...
In Pedigree constructor you need to instantiate the property classes as well, they are not instantiated so it throws null reference exception: public Pedigree() { this.Mother = new Dog{Name = "Chanelle", Merit1 = "Universal"}; this.Father = new Dog{Name = "dfdfdf", Merit1 = "dfdfdfdfdf"}; this.GrandFather = new Dog(); this.GrandMother = new...
I had Common Language Runtime exceptions to be thrown, disabled that and now it works ...
That is just standard JS: throw "Too big"; // throw a text throw 500; // throw a number ...
X-Y problem - instead of converting byte array into version that is known to be correctly handled as string with Base64 (or similar) you using UTF8 as encoding. Reading random byte array as UTF8 string will have non-printable and 0 characters as well random failures due to incorrect UTF8 sequences....
RavenDB uses HILO algorithm to generate identities by default. "Hi (High)" values are saved in the server while "Lo (Low)" values are maintained in the client. What you see in the studio are the "Hi" values: http://ravendb.net/docs/article-page/3.0/csharp/client-api/document-identifiers/hilo-algorithm Here is a good blog post explains how HiLo algorithm works: http://codeofrob.com/entries/ravendb---the-hilo-what-how-and-why.html...
If you want to do random ordering, you can do that directly, instead of like this: http://ravendb.net/docs/article-page/3.0/csharp/client-api/session/querying/how-to-customize-query#randomordering List<Employee> results = session.Query<Employee>() .Customize(x => x.RandomOrdering()) .Where(x => x.FirstName == "Robert") .ToList(); ...