Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Euan Rae 105 posts 135 karma points
    Dec 01, 2011 @ 16:22
    Euan Rae
    1

    Getting all items from an examine index

    I'm using Examine to server content in v4.7.1 (for performance reasons).  I want to be able to get all of the items in a particular index

    I've tried

    var results = ExamineManager.Instance.SearchProviderCollection["MySearcher"].Search(string.Empty, true);

    but it throwns an error.

    How can get all the items in the index?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Dec 01, 2011 @ 23:59
    Bo Damgaard Mortensen
    1

    Hi Euan,

    Have you had a peek at your index with Luke ? Just to see if there is something general you can search for.

    I actually had the same question a week ago and Ismail was kind enough to tell me how to solve it. Could you please try something like:

    var mySearcher = ExamineManager.Instance.SearchProviderCollection["MySearcher"];
    var criteria = mySearcher.CreateSearchCriteria(IndexTypes.Content);
    var results = mySearcher.Search(criteria.Compile()); 

    See if that gives any results at all :-)

    All the best,

    Bo

  • Barry Fogarty 493 posts 1129 karma points
    Dec 02, 2011 @ 00:05
    Barry Fogarty
    0

    I had a similar issue but I had a flag (IsPublic) I was able to add and perform a search based on that being 1.  Equally you could try a search for an id > 0 I imagine.

    The Umbrac video series re Examine is very useful too, just to make sure the index is all set up right and shows you how to use Luke.

  • Euan Rae 105 posts 135 karma points
    Dec 02, 2011 @ 13:29
    Euan Rae
    1

    Hi Bo,

    Thanks for the tip, I couldn't quite get that code working, but got it to work like so:

    var searcher = ExamineManager.Instance.SearchProviderCollection[examineSearcher];
    var searchCriteria = searcher.CreateSearchCriteria(IndexTypes.Content);           
    var results = searcher.Search(searchCriteria.SearchIndexType, true); 

     

    Barry, I thought of doing something like that, but wanted to do more of a select * type thing than fake it by searching on a field, thanks anyway

    Cheers,

    Euan


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Dec 03, 2011 @ 17:11
    Bo Damgaard Mortensen
    0

    Hi Euan,

    Brilliant! Remember to mark your post as 'Solved' for future reference :-)

    - Bo

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 31, 2012 @ 20:12
    Tom Fulton
    1

    I couldn't get either of these to work, but Ismail mentioned a tip at his Umbraco UK Fest presentation.  The idea was to use the GatheringNodeData event to add a "dummy" field to all nodes, then you can query for this field.  Here's my event, and my search just looks for allDocs = 1

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Examine;
    using umbraco.businesslogic;

    namespace Client.Umbraco.Extensions.Events
    {
        public class CenterSearch : ApplicationStartupHandler
        {
            public CenterSearch()
            {
                ExamineManager.Instance.IndexProviderCollection[Constants.INDEXER_NAME].GatheringNodeData += CenterSearch_GatheringNodeData;
            }
            void CenterSearch_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
            {
                // Add a dummy value so its easy to get all docs
                e.Fields.Add("allDocs", "1");
    // Other stuff
            }
        }
    }

    -Tom

  • kristian schneider 190 posts 351 karma points
    Oct 02, 2014 @ 16:13
    kristian schneider
    8

    I ended up doing it like this:

      ISearchCriteria searchCriteria = searcher.CreateSearchCriteria();
               var query = searchCriteria.Range("updateDate", DateTime.MinValue, DateTime.MaxValue);
                var results = searcher.Search(query.Compile());
Please Sign in or register to post replies

Write your reply to:

Draft