Copied to clipboard

Flag this post as spam?

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


  • eshan 12 posts 42 karma points
    Nov 06, 2012 @ 11:46
    eshan
    0

    Examine to index search with custom DB fields

    I'm tring to create custom index for my database fields. But my code only genarates folders without any index files. Below is the my code please someone help me to figure this out.

    My ExmineIndex.config

     

    <?xml version="1.0"?>
    <ExamineLuceneIndexSets>
    <!-- Search Custom DB Fields -->
      <IndexSet SetName="VacationFinderIndexSet" IndexPath="~/App_Data/ExamineIndexes/VacationFinder/">
        <IndexUserFields>
            <add Name="id" />
            <add Name="title" />
        </IndexUserFields>
      </IndexSet>
    </ExamineLuceneIndexSets>
    My ExamineSettings.config
    <?xml version="1.0"?>
    
    <Examine>
      <ExamineIndexProviders>
    <providers>
    
    <add name="VacationFinderIndexer"
               type="Examine.LuceneEngine.Providers.SimpleDataIndexer, Examine"
               dataService="SearchIndexProj.VacationFinderDataService, SearchIndexProj"
               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
               indexTypes="CustomData"
               indexSet="VacationFinderIndexSet"
               runAsync="false"/>
        
        </providers>
      </ExamineIndexProviders>
    
    
    <ExamineSearchProviders defaultProvider="ExternalSearcher">
    <providers>
    <!-- Search Custom DB Fields -->
    
    
     <add name="VacationFinderSearcher"
               type="Examine.LuceneEngine.Providers.LuceneSearcher, Examine"
               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
               indexSet="VacationFinderIndexSet" />
        </providers>
      </ExamineSearchProviders>

    My VacationFinderDataService.cs(for now I'm assigning dummy data manually.)

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using Examine.LuceneEngine;

    using Examine;


    namespace SearchIndexProj

    {

        public class VacationFinderDataService : ISimpleDataService

        {


            public IEnumerable<SimpleDataSet> GetAllData(string indexType)

            {

                List<Vacation> _vac = new List<Vacation>();

                _vac.Add(new Vacation { Id = 1, Title = "abc" });

                _vac.Add(new Vacation { Id = 2, Title = "cde" });

                _vac.Add(new Vacation { Id = 3, Title = "asd" });

                _vac.Add(new Vacation { Id = 4, Title = "dfg" });

                _vac.Add(new Vacation { Id = 5, Title = "fgh" });

                _vac.Add(new Vacation { Id = 6, Title = "w4e" });

                _vac.Add(new Vacation { Id = 7, Title = "hjk" });


                var data = new List<SimpleDataSet>();


                foreach (var item in _vac)

                {

                    data.Add(new SimpleDataSet()

                    {

                        NodeDefinition = new IndexedNode()

                        {

                            NodeId = item.Id,

                            Type = "CustomData"

                        },

                        RowData = new Dictionary<string, string>()

                        {

                            {"id", item.Id.ToString()},

                            {"title", item.Title}

                        }

                    });

                }

                return data;

            }

        }


        public class Vacation

        {

            public int Id { get; set; }

            public string Title { get; set; }

        }

    }

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 06, 2012 @ 12:57
    Dirk De Grave
    0

    Have you checked the umbracoLog table if there's any exception being logged?

     

    Cheers,

    Dirk

  • eshan 12 posts 42 karma points
    Nov 06, 2012 @ 17:15
    eshan
    0

    Yes I have checked. There is no any exception.

  • eshan 12 posts 42 karma points
    Nov 07, 2012 @ 08:34
    eshan
    0

    found a solution, we need to manually invoke GetAllData method like bellow,

    ExamineManager.Instance.IndexProviderCollection["VacationFinderIndexer"].RebuildIndex();

    this will create the index files.

  • Rosauro Luz 3 posts 72 karma points
    Aug 19, 2015 @ 16:57
    Rosauro Luz
    0

    Where will you invoke this eshan?

Please Sign in or register to post replies

Write your reply to:

Draft