Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:15:28+00:00 2026-06-02T05:15:28+00:00

For all documents satisfying a given criteria, I would like to patch update a

  • 0

For all documents satisfying a given criteria, I would like to patch update a field in those documents. For this, I wrote a query in LINQ Pad that gets me the subset of documents needed.

That is :

Session.Query<Movie>()    
.Where(x => x.Status == "Released" && x.IsDeleted == false && x.ReleaseDate.Date < new DateTime(2012, 4, 3))
.Dump();

Now I have the list of documents. But I need to modify a field. For this I wrote an index and patch command.. I need help completing this task.

Patch code (incomplete) :

  store.DatabaseCommands.UpdateByIndex("Movies/NewIndexName",
         new IndexQuery { Query = "IsDeleted:false" },
         new[]
        {
          new PatchRequest
              {
                  Type = PatchCommandType.Modify,
                  Name = "Status",
                  Value = "Testing"
               }
        }, allowStale: false);

Index is

  from doc in docs.Movies
  select new { ReleaseDate = doc.ReleaseDate.Date, IsDeleted = doc.IsDeleted, Status =

  doc.Status }

Specifically my question is.. is my approach correct.. and if it is, how do I add multiple criteria in the condition.. where it says Query = “IsDeleted:false” can I add more comparison checks to the query (like in the LINQ query above)?

EDIT: (USING DANIEL LANG’S SOLUTION)

This gives format exception.. Input string not in correct format.

store.DatabaseCommands.UpdateByIndex("Movies/NewIndexName",
             new IndexQuery
             {
                 Query =
         string.Format("Status:Released AND IsDeleted:false AND ReleaseDate:{* TO {0}}",
         DateTools.DateToString(new DateTime(2012, 4, 3),
                                DateTools.Resolution.MILLISECOND))
             },
             new[]
            {
              new PatchRequest
                  {
                      Type = PatchCommandType.Modify,
                      Name = "Status",
                      Value = "TestingReleased"
                   }
            }, allowStale: false);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:15:30+00:00Added an answer on June 2, 2026 at 5:15 am

    Yes, you can have multiple conditions and combine them using standard boolean operations. You’re actually building a lucene query here, so let’s take a look at this website to learn more about how you can write them: http://lucene.apache.org/core/old_versioned_docs/versions/2_9_1/queryparsersyntax.html#Boolean%20operators

    The thing about dates is, that raven stores them (as everything else) as a string and the format it uses is specifically chosen to enable range queries and that kind of stuff, so it might not be what you expect…

    So in order to query for the date, you need to format it in a special way. There is a class DateTools inside Raven.Abstractions.Linq that has a DateToString method that helps.

    You can construct the same query from above like this:

    (EDITED 4/27 to add an extra {} in the string)

    Query = 
        string.Format("IsDeleted:false AND ReleaseDate:{{* TO {0}}}",
        DateTools.DateToString(new DateTime(2012,4,3), 
                               DateTools.Resolution.MILISECONDS))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way using LINQ to query for all documents that a user
Via SugarCRM i would like to have all documents listed in an opportunity show
I have a collection I'd like to query as follows: return all documents up
I have created a lucene index . I would like to get all documents
I'm using caml query to select all documents which were modified or added by
remove() method without any argument removes all documents inside the collection. $this->db->$collection->remove(); But how
Suppose I want to query for only a certain attribute of all documents, something
If we want to search a query like this t1 t2 t3 (t1,t2 ,t3
How do I remove all documents in a collection where a field's value isn't
Is there any way in couchdb to update all documents matching certain conditions? (e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.