anchor.diff:      
       [<Sealed>]
       type Service(analyzerService, store) = 
  -        let state = create (analyzerService, store)
  +        let state = State.create (analyzerService, store)
           do state |> loadAllIndex
           interface IIndexService with
               member __.GetIndex(indexName) = state |> getIndex (indexName)
  
positive.code: // ----------------------------------------------------------------------------
  namespace FlexSearch.Core
  
  module IndexService = 
      open System
      open System.Collections.Concurrent
      open System.IO
      open System.Linq
      open System.Threading.Tasks
      
      type T = 
          { IndexStates : ConcurrentDictionary<string, IndexState>
            IndexWriters : ConcurrentDictionary<string, IndexWriter.T>
            AnalyzerService : LazyFactory<FlexLucene.Analysis.Analyzer, Analyzer.T>
            Store : State.Store }
          member this.GetIndices() = this.Store.GetItems<Index.T>()
          member this.GetIndex(indexName) = this.Store.GetItem<Index.T>(indexName)
      
      let create (service, store) = 
          { IndexStates = conDict<IndexState>()
            IndexWriters = conDict<IndexWriter.T>()
            AnalyzerService = service
            Store = store }
      
      let indexNotFound (indexName) = IndexNotFound <| indexName
      let indexExists (indexName) (state : T) = state.IndexStates |> keyExists (indexName, indexNotFound)
      let getIndexWriter (indexName) (state : T) = state.IndexWriters |> keyExists (indexName, indexNotFound)
      let getIndexState (indexName) (state : T) = state.IndexStates |> keyExists (indexName, indexNotFound)
      
      let updateState (indexName, indexState : IndexState) (state : T) = 
          match state.IndexStates.TryGetValue(indexName) with
          | true, v -> state.IndexStates.TryUpdate(indexName, indexState, v) |> ignore
          | _ -> raise (ValidationException(IndexNotFound(indexName)))
      
      /// Load a index
      let loadIndex (index : Index.T) (state : T) = 
          let setting = IndexWriter.createIndexSetting (index, state.AnalyzerService)
          if Args.getBool index.Online then 
              state.IndexStates |> addOrUpdate (index.IndexName, IndexState.Opening)
              state.IndexWriters |> add (index.IndexName, IndexWriter.create (setting))
          else state.IndexStates |> addOrUpdate (index.IndexName, IndexState.Offline)
      
      let openIndex (indexName) (state : T) = 
          maybe { 
              let! indexState = state |> getIndexState indexName
              let! index = state.GetIndex indexName
              let updatedIndex = { index with Online = Nullable(true) }
              state.Store.UpdateItem(index.IndexName, updatedIndex)
              let setting = IndexWriter.createIndexSetting (updatedIndex, state.AnalyzerService)
              state |> loadIndex updatedIndex
          }
      
      let closeIndex (indexName) (state : T) = 
          maybe { 
              let! indexState = state |> getIndexState indexName
              let! index = state.GetIndex(indexName)
              let updatedIndex = { index with Online = Nullable(false) }
              state.Store.UpdateItem(index.IndexName, updatedIndex)
              state.IndexWriters.[indexName] |> IndexWriter.close
              state.IndexWriters |> remove indexName
          }
      
      /// Load all index from the store
      let loadAllIndex (state : T) = 
          state.GetIndices()
          |> Seq.map (fun i -> new Task(fun _ -> loadIndex i state))
          |> Seq.toArray
          |> Task.WaitAll
      
      /// Add a new index
      let addIndex (index : Index.T) (state : T) = 
          maybe { 
              do! (index :> IValidate).Validate()
              let _ = state |> indexExists index.IndexName
              state |> loadIndex index
              return CreateResponse(index.IndexName)
          }
      
      /// Get index by name
      let getIndex (indexName) (state : T) = state.GetIndex(indexName)
      
      /// Get all available index
      let getAllIndices (state : T) = state.GetIndices().ToArray()
      
      /// Delete an existing index    
      let deleteIndex (indexName) (s : T) = 
          IndexWriter.close (s.IndexWriters.[indexName])
          let info = s.IndexWriters.[indexName]
          s.Store.DeleteItem(indexName)
  
negative.code:         delDir (info.Settings.BaseFolder)
          ok()
      
      let updateIndex (index : Index.T) (state : State.T) = 
          maybe { 
              let! iw = state |> getIndexWriter index.IndexName
              let! indexState = state |> getIndexState index.IndexName
  