private Query CompileSearchExpressionNode(SearchExpression expression) { if (!(expression.Parent is NodeQuery)) throw new NotSupportedException(); if (_searchExpression != null) throw new NotSupportedException(); _searchExpression = expression; if (_hasFullTextSearch) throw new NotSupportedException("More than one fulltext expression!"); _hasFullTextSearch = true; var text = expression.FullTextExpression.Trim('"').TrimEnd('*'); //var phrases = text.Split(" \r\n\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var phrases = TextSplitter.SplitText(null, text, _analyzers); if (phrases.Length > 1) { //_Text:"text text text" var phq = new PhraseQuery(); var validPhrases = phrases.Except(Lucene.Net.Analysis.Standard.StandardAnalyzer.STOP_WORDS); foreach (var phrase in validPhrases) phq.Add(new Term(LucObject.FieldName.AllText, phrase)); return phq; } //_Text:text var term = new Term(LucObject.FieldName.AllText, text); var result = new TermQuery(term); return result; }
public void ReferenceExpression_Constuctor() { PropertyType slot = new SchemaEditor().CreatePropertyType("slot", DataType.Reference); SearchExpression exp = new SearchExpression("FullTextExpression"); Node node = Repository.Root; ReferenceExpression refExp; refExp = new ReferenceExpression(ReferenceAttribute.Parent); refExp = new ReferenceExpression(slot); refExp = new ReferenceExpression(ReferenceAttribute.Parent, exp); refExp = new ReferenceExpression(slot, exp); refExp = new ReferenceExpression(ReferenceAttribute.Parent, node); refExp = new ReferenceExpression(slot, node); }
public void NotExpression_Constructor_String() { SearchExpression exp = new SearchExpression("FullTextExpression"); NotExpression notExp = new NotExpression(exp); //NotExpressionAccessor acc = new NotExpressionAccessor(notExp); Assert.IsTrue(Object.ReferenceEquals(notExp.Expression, exp)); }
public void SearchExpression_Constructor_String() { SearchExpression exp = new SearchExpression("FullTextExpression"); //SearchExpressionAccessor acc = new SearchExpressionAccessor(exp); Assert.IsTrue(exp.FullTextExpression == "FullTextExpression"); }
public void SearchExpression_Constructor_Null() { SearchExpression exp = new SearchExpression(null); //SearchExpressionAccessor acc = new SearchExpressionAccessor(exp); Assert.IsTrue(exp.FullTextExpression == ""); }
public void NodeQuery_Bug2125() { Expression exp; ExpressionList expList; var query1 = new NodeQuery(); exp = new SearchExpression("dummy"); query1.Add(exp); Assert.IsTrue(Object.ReferenceEquals( exp.Parent, query1), "#1"); expList = new ExpressionList(ChainOperator.And); query1.Add(expList); Assert.IsTrue(Object.ReferenceEquals(expList.Parent, query1), "#2"); exp = new StringExpression(StringAttribute.Name, StringOperator.Equal, "Root"); expList.Add(exp); Assert.IsTrue(Object.ReferenceEquals(exp.Parent, expList), "#3"); exp = new IntExpression(IntAttribute.Id, ValueOperator.Equal, 2); expList.Add(exp); Assert.IsTrue(Object.ReferenceEquals(exp.Parent, expList), "#4"); //------------------------------------------------------------------------------------ var query2 = new NodeQuery ( new SearchExpression("dummy"), new ExpressionList ( ChainOperator.And, new StringExpression(StringAttribute.Name, StringOperator.Equal, "Root"), new IntExpression(IntAttribute.Id, ValueOperator.Equal, 2) ) ); Assert.IsTrue(Object.ReferenceEquals(query2.Expressions[0].Parent, query2), "#5"); Assert.IsTrue(Object.ReferenceEquals(query2.Expressions[1].Parent, query2), "#6"); Assert.IsTrue(Object.ReferenceEquals(((ExpressionList)query2.Expressions[1]).Expressions[0].Parent, query2.Expressions[1]), "#7"); Assert.IsTrue(Object.ReferenceEquals(((ExpressionList)query2.Expressions[1]).Expressions[1].Parent, query2.Expressions[1]), "#8"); }