Esempio n. 1
0
        internal static Query GetPathQuery(string path, bool inTree)
        {
            if (path == null)
            {
                return(null);
            }

            FieldIndexHandler converter = null;
            string            fieldName = null;

            if (inTree)
            {
                converter = new InTreeIndexHandler();
                fieldName = LucObject.FieldName.InTree;
            }
            else
            {
                converter = new InFolderIndexHandler();
                fieldName = LucObject.FieldName.InFolder;
            }

            var qvalue = new QueryFieldValue(path);

            converter.ConvertToTermValue(qvalue);
            return(new TermQuery(new Term(fieldName, qvalue.StringValue)));
        }
        public void FieldIndexHandler_InFolderIndexHandler()
        {
            var fieldValue       = "/Root/A/B";
            var fieldValueObject = (object)fieldValue;
            var snField          = new IndexableField(fieldValueObject);

            var fieldIndexHandler = new InFolderIndexHandler();

            fieldIndexHandler.OwnerIndexingInfo = new TestPerfieldIndexingInfoString();

            var indexed   = fieldIndexHandler.GetIndexFields(snField, out _);
            var parsed    = fieldIndexHandler.Parse(fieldValue.ToString());
            var termValue = fieldIndexHandler.ConvertToTermValue(fieldValue);

            Assert.AreEqual(indexed.First().Type, parsed.Type);
            Assert.AreEqual(parsed.Type, termValue.Type);

            var retrieved = fieldIndexHandler.GetBack("/Root/A/B");

            Assert.AreEqual(fieldValue, retrieved);
        }