Пример #1
0
        public void DeleteFromIndex(LuceneIndexType type, long id)
        {
            var action = GetLuceneAction(type, null, true, id);

            if (!LuceneUtil.Instance.ModifyIndex(action))
            {
                AddActionToQueue(action);
            }
        }
Пример #2
0
        public void AddToIndex(LuceneIndexType type, dynamic data)
        {
            var action = GetLuceneAction(type, data, false, data.id);

            if (!LuceneUtil.Instance.ModifyIndex(action))
            {
                AddActionToQueue(action);
            }
        }
Пример #3
0
        public void AddActionToIndexingQueue(LuceneIndexType type, XElement data, long subdomainid, bool deleteOnly, long itemKey)
        {
            var single = new indexingQueue();

            single.subdomainid    = subdomainid;
            single.serializedItem = data;
            single.itemKey        = itemKey;
            single.deleteOnly     = deleteOnly;
            single.type           = (byte)type;

            db.indexingQueues.InsertOnSubmit(single);
        }
Пример #4
0
 private IndexWriter CreateWriter(LuceneIndexType type, string subdomain)
 {
     try
     {
         fsdir  = GetDirectoryInfo(type, subdomain);
         writer = new IndexWriter(fsdir, analyzer, true, new IndexWriter.MaxFieldLength(100000));
         return(writer);
     }
     catch (Exception ex)
     {
         Syslog.Write(ex);
     }
     return(null);
 }
Пример #5
0
        public static FSDirectory GetDirectoryInfo(LuceneIndexType type, string subdomain)
        {
            DirectoryInfo dir;
            // add contacts index
            var path = Path.Combine(string.Concat(GeneralConstants.APP_ROOT_DIR, GeneralConstants.LUCENE_INDEX_LOCATION, "\\", subdomain),
                                    type.ToString());

            if (!System.IO.Directory.Exists(path))
            {
                dir = System.IO.Directory.CreateDirectory(path);
            }
            else
            {
                dir = new DirectoryInfo(path);
            }
            return(FSDirectory.Open(dir));
        }
Пример #6
0
        private LuceneAction GetLuceneAction(LuceneIndexType type, dynamic data, bool deleteOnly, long itemKey)
        {
            var action = new LuceneAction
            {
                type          = type,
                subdomainName = subdomain.name,
                deleteOnly    = deleteOnly,
                itemKey       = itemKey
            };

            if (data == null)
            {
                action.data = BaseQueueItem.Serialize(new BaseQueueItem(itemKey.ToString(), type));
            }
            else
            {
                switch (type)
                {
                case LuceneIndexType.CONTACTS:
                    action.data = new ContactItem(data);
                    break;

                case LuceneIndexType.PRODUCTS:
                    action.data = new ProductItem(data);
                    break;

                case LuceneIndexType.TRANSACTION:
                    action.data = new TransactionItem(data);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("type");
                }
            }

            return(action);
        }
Пример #7
0
 public BaseQueueItem(string id, LuceneIndexType indexType)
 {
     this.id        = id;
     this.indexType = indexType;
 }