/// <summary> /// Creates our own style 'multi field query' used internal for the grouped operations /// </summary> /// <param name="fields"></param> /// <param name="fieldVals"></param> /// <param name="occurance"></param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> protected internal BooleanQuery GetMultiFieldQuery(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance) { //if there's only 1 query text we want to build up a string like this: //(!field1:query !field2:query !field3:query) //but Lucene will bork if you provide an array of length 1 (which is != to the field length) var queryVals = new IExamineValue[fields.Length]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) { queryVals[i] = fieldVals[0]; } } else { queryVals = fieldVals; } var qry = new BooleanQuery(); for (int i = 0; i < fields.Length; i++) { qry.Add(this.GetFieldInternalQuery(fields[i], queryVals[i]), occurance); } return(qry); }
protected internal IBooleanOperation NodeTypeAliasInternal(IExamineValue examineValue, BooleanClause.Occur occurance) { //force lower case var eVal = new ExamineValue(examineValue.Examineness, examineValue.Value.ToLower(), examineValue.Level); //don't use the query parser for this operation, it needs to match exact return(this.FieldInternal(NodeTypeAliasField, eVal, occurance, false)); }
private static void ValidateIExamineValue(IExamineValue v) { var ev = v as ExamineValue; if (ev == null) { throw new ArgumentException("IExamineValue was not created from this provider. Ensure that it is created from the ISearchCriteria this provider exposes"); } }
private static void ValidateIExamineValue(IExamineValue v) { var ev = v as ExamineValue; if (ev == null) { throw new ArgumentException("IExamineValue was not created from this provider. Ensure that it is created from the ISearchCriteria this provider exposes"); } }
protected internal IBooleanOperation FieldInternal(string fieldName, IExamineValue fieldValue, BooleanClause.Occur occurance, bool useQueryParser) { Query queryToAdd = GetFieldInternalQuery(fieldName, fieldValue, useQueryParser); if (queryToAdd != null) { Query.Add(queryToAdd, occurance); } return(new LuceneBooleanOperation(this)); }
private LuceneBooleanOperationBase FieldInternal(string fieldName, IExamineValue fieldValue, Occur occurrence, bool useQueryParser) { Query queryToAdd = GetFieldInternalQuery(fieldName, fieldValue, useQueryParser); if (queryToAdd != null) { Query.Add(queryToAdd, occurrence); } return(CreateOp()); }
/// <summary> /// Sets up an <see cref="IExamineValue"/> for an additional Examiness /// </summary> /// <param name="examineValue">The IExamineValue to continue working with.</param> /// <param name="s">The string to postfix.</param> /// <returns>Combined strings</returns> public static string Then(this IExamineValue examineValue, string s) { if (examineValue == null) { throw new ArgumentNullException("examineValue", "examineValue is null."); } if (String.IsNullOrEmpty(s)) { throw new ArgumentException("Supplied string is null or empty.", "s"); } return(examineValue.Value + s); }
protected internal BooleanQuery GetMultiFieldQuery( string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance, bool matchAllCombinations = false) { var qry = new BooleanQuery(); if (matchAllCombinations) { foreach (var f in fields) { foreach (var val in fieldVals) { var q = GetFieldInternalQuery(f, val, true); if (q != null) { qry.Add(q, occurance); } } } } else { var queryVals = new IExamineValue[fields.Length]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) { queryVals[i] = fieldVals[0]; } } else { queryVals = fieldVals; } for (int i = 0; i < fields.Length; i++) { var q = GetFieldInternalQuery(fields[i], queryVals[i], true); if (q != null) { qry.Add(q, occurance); } } } return(qry); }
private BooleanQuery GetMultiFieldQuery( IReadOnlyList <string> fields, IExamineValue[] fieldVals, Occur occurrence, bool matchAllCombinations = false) { var qry = new BooleanQuery(); if (matchAllCombinations) { foreach (var f in fields) { foreach (var val in fieldVals) { var q = GetFieldInternalQuery(f, val, true); if (q != null) { qry.Add(q, occurrence); } } } } else { var queryVals = new IExamineValue[fields.Count]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) { queryVals[i] = fieldVals[0]; } } else { queryVals = fieldVals; } for (int i = 0; i < fields.Count; i++) { var q = GetFieldInternalQuery(fields[i], queryVals[i], true); if (q != null) { qry.Add(q, occurrence); } } } return(qry); }
/// <summary> /// Returns the Lucene query object for a field given an IExamineValue /// </summary> /// <param name="fieldName"></param> /// <param name="fieldValue"></param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> internal protected Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue) { Query queryToAdd; switch (fieldValue.Examineness) { case Examineness.Fuzzy: queryToAdd = this.queryParser.GetFuzzyQuery(fieldName, fieldValue.Value, fieldValue.Level); break; case Examineness.SimpleWildcard: case Examineness.ComplexWildcard: queryToAdd = this.queryParser.GetWildcardQuery(fieldName, fieldValue.Value); break; case Examineness.Boosted: queryToAdd = this.queryParser.GetFieldQuery(fieldName, fieldValue.Value); queryToAdd.SetBoost(fieldValue.Level); break; case Examineness.Proximity: //This is how you are supposed to do this based on this doc here: //http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/spans/package-summary.html#package_description //but i think that lucene.net has an issue with it's internal parser since it parses to a very strange query //we'll just manually make it instead below //var spans = new List<SpanQuery>(); //foreach (var s in fieldValue.Value.Split(' ')) //{ // spans.Add(new SpanTermQuery(new Term(fieldName, s))); //} //queryToAdd = new SpanNearQuery(spans.ToArray(), Convert.ToInt32(fieldValue.Level), true); var proxQuery = fieldName + ":\"" + fieldValue.Value + "\"~" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = queryParser.Parse(proxQuery); break; case Examineness.Explicit: default: queryToAdd = this.queryParser.GetFieldQuery(fieldName, fieldValue.Value); break; } return(queryToAdd); }
protected internal IBooleanOperation GroupedFlexibleInternal(string[] fields, BooleanOperation[] operations, IExamineValue[] fieldVals, BooleanClause.Occur occurance) { //if there's only 1 query text we want to build up a string like this: //(field1:query field2:query field3:query) //but Lucene will bork if you provide an array of length 1 (which is != to the field length) var flags = new BooleanClause.Occur[operations.Length]; for (int i = 0; i < flags.Length; i++) { flags[i] = operations[i].ToLuceneOccurance(); } var queryVals = new IExamineValue[fields.Length]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) { queryVals[i] = fieldVals[0]; } } else { queryVals = fieldVals; } var qry = new BooleanQuery(); for (int i = 0; i < fields.Length; i++) { var q = GetFieldInternalQuery(fields[i], queryVals[i], true); if (q != null) { qry.Add(q, flags[i]); } } this.Query.Add(qry, occurance); return(new LuceneBooleanOperation(this)); }
/// <summary> /// Query method to search on node type alias /// </summary> /// <param name="query"></param> /// <param name="nodeTypeAlias"></param> /// <returns></returns> public static IBooleanOperation NodeTypeAlias(this IQuery query, IExamineValue nodeTypeAlias) { var fieldQuery = query.Field(ExamineFieldNames.ItemTypeFieldName, nodeTypeAlias); return(fieldQuery); }
protected internal new LuceneBooleanOperationBase FieldInternal(string fieldName, IExamineValue fieldValue, Occur occurrence) { if (fieldName == null) { throw new ArgumentNullException(nameof(fieldName)); } if (fieldValue == null) { throw new ArgumentNullException(nameof(fieldValue)); } return(FieldInternal(fieldName, fieldValue, occurrence, true)); }
/// <summary> /// Query on the NodeTypeAlias /// </summary> /// <param name="nodeTypeAlias">The node type alias.</param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias) { return this.search.NodeTypeAliasInternal(nodeTypeAlias, occurance); }
/// <summary> /// Query method to search on node type alias /// </summary> /// <param name="query"></param> /// <param name="nodeTypeAlias"></param> /// <returns></returns> public static IBooleanOperation NodeTypeAlias(this IQuery query, IExamineValue nodeTypeAlias) { var fieldQuery = query.Field("__NodeTypeAlias", nodeTypeAlias); return(fieldQuery); }
protected internal Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue, bool useQueryParser) { Query queryToAdd; switch (fieldValue.Examineness) { case Examineness.Fuzzy: if (useQueryParser) { queryToAdd = this.QueryParser.GetFuzzyQuery(fieldName, fieldValue.Value, fieldValue.Level); } else { //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Fuzzy%20Searches var proxQuery = fieldName + ":" + fieldValue.Value + "~" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.SimpleWildcard: case Examineness.ComplexWildcard: if (useQueryParser) { queryToAdd = this.QueryParser.GetWildcardQuery(fieldName, fieldValue.Value); } else { //this will already have a * or a . suffixed based on the extension methods //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Wildcard%20Searches var proxQuery = fieldName + ":" + fieldValue.Value; queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.Boosted: if (useQueryParser) { queryToAdd = this.QueryParser.GetFieldQuery(fieldName, fieldValue.Value); queryToAdd.SetBoost(fieldValue.Level); } else { //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boosting%20a%20Term var proxQuery = fieldName + ":\"" + fieldValue.Value + "\"^" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.Proximity: //This is how you are supposed to do this based on this doc here: //http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/spans/package-summary.html#package_description //but i think that lucene.net has an issue with it's internal parser since it parses to a very strange query //we'll just manually make it instead below //var spans = new List<SpanQuery>(); //foreach (var s in fieldValue.Value.Split(' ')) //{ // spans.Add(new SpanTermQuery(new Term(fieldName, s))); //} //queryToAdd = new SpanNearQuery(spans.ToArray(), Convert.ToInt32(fieldValue.Level), true); var qry = fieldName + ":\"" + fieldValue.Value + "\"~" + Convert.ToInt32(fieldValue.Level).ToString(); if (useQueryParser) { queryToAdd = QueryParser.Parse(qry); } else { queryToAdd = ParseRawQuery(qry); } break; case Examineness.Escaped: //when an item is escaped it should be an exact match // http://examine.codeplex.com/workitem/10359 //standard query ... no query parser var stdQuery = fieldName + ":" + fieldValue.Value; queryToAdd = ParseRawQuery(stdQuery); break; case Examineness.Explicit: default: if (useQueryParser) { queryToAdd = this.QueryParser.GetFieldQuery(fieldName, fieldValue.Value); } else { //standard query var proxQuery = fieldName + ":" + fieldValue.Value; queryToAdd = ParseRawQuery(proxQuery); } break; } return(queryToAdd); }
/// <summary> /// Creates our own style 'multi field query' used internal for the grouped operations /// </summary> /// <param name="fields"></param> /// <param name="fieldVals"></param> /// <param name="occurance"></param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> protected internal BooleanQuery GetMultiFieldQuery(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance) { //if there's only 1 query text we want to build up a string like this: //(!field1:query !field2:query !field3:query) //but Lucene will bork if you provide an array of length 1 (which is != to the field length) var queryVals = new IExamineValue[fields.Length]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) queryVals[i] = fieldVals[0]; } else { queryVals = fieldVals; } var qry = new BooleanQuery(); for (int i = 0; i < fields.Length; i++) { qry.Add(this.GetFieldInternalQuery(fields[i], queryVals[i]), occurance); } return qry; }
protected internal IBooleanOperation GroupedOrInternal(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance) { //if there's only 1 query text we want to build up a string like this: //(field1:query field2:query field3:query) //but Lucene will bork if you provide an array of length 1 (which is != to the field length) Query.Add(GetMultiFieldQuery(fields, fieldVals, BooleanClause.Occur.SHOULD, true), occurance); return new LuceneBooleanOperation(this); }
protected internal IBooleanOperation GroupedNotInternal(string[] fields, IExamineValue[] fieldVals) { //if there's only 1 query text we want to build up a string like this: //(!field1:query !field2:query !field3:query) //but Lucene will bork if you provide an array of length 1 (which is != to the field length) Query.Add(GetMultiFieldQuery(fields, fieldVals, BooleanClause.Occur.MUST_NOT, true), //NOTE: This is important because we cannot prefix a + to a group of NOT's, that doesn't work. // for example, it cannot be: +(-id:1 -id:2 -id:3) // it just needs to be (-id:1 -id:2 -id:3) BooleanClause.Occur.SHOULD); return new LuceneBooleanOperation(this); }
internal protected IBooleanOperation FieldInternal(string fieldName, IExamineValue fieldValue, BooleanClause.Occur occurance, bool useQueryParser) { Query queryToAdd = GetFieldInternalQuery(fieldName, fieldValue, useQueryParser); if (queryToAdd != null) Query.Add(queryToAdd, occurance); return new LuceneBooleanOperation(this); }
public IBooleanOperation GroupedAnd(IEnumerable<string> fields, IExamineValue[] fieldVals) { Enforcer.ArgumentNotNull(fields, "fields"); Enforcer.ArgumentNotNull(Query, "fieldVals"); return this.GroupedAndInternal(fields.ToArray(), fieldVals.ToArray(), _occurance); }
internal protected IBooleanOperation FieldInternal(string fieldName, IExamineValue fieldValue, BooleanClause.Occur occurance) { return FieldInternal(fieldName, fieldValue, occurance, true); }
internal protected Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue, bool useQueryParser) { Query queryToAdd; switch (fieldValue.Examineness) { case Examineness.Fuzzy: if (useQueryParser) { queryToAdd = this.QueryParser.GetFuzzyQuery(fieldName, fieldValue.Value, fieldValue.Level); } else { //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Fuzzy%20Searches var proxQuery = fieldName + ":" + fieldValue.Value + "~" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.SimpleWildcard: case Examineness.ComplexWildcard: if (useQueryParser) { queryToAdd = this.QueryParser.GetWildcardQuery(fieldName, fieldValue.Value); } else { //this will already have a * or a . suffixed based on the extension methods //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Wildcard%20Searches var proxQuery = fieldName + ":" + fieldValue.Value; queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.Boosted: if (useQueryParser) { queryToAdd = this.QueryParser.GetFieldQuery(fieldName, fieldValue.Value); queryToAdd.SetBoost(fieldValue.Level); } else { //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boosting%20a%20Term var proxQuery = fieldName + ":\"" + fieldValue.Value + "\"^" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.Proximity: //This is how you are supposed to do this based on this doc here: //http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/spans/package-summary.html#package_description //but i think that lucene.net has an issue with it's internal parser since it parses to a very strange query //we'll just manually make it instead below //var spans = new List<SpanQuery>(); //foreach (var s in fieldValue.Value.Split(' ')) //{ // spans.Add(new SpanTermQuery(new Term(fieldName, s))); //} //queryToAdd = new SpanNearQuery(spans.ToArray(), Convert.ToInt32(fieldValue.Level), true); var qry = fieldName + ":\"" + fieldValue.Value + "\"~" + Convert.ToInt32(fieldValue.Level).ToString(); if (useQueryParser) { queryToAdd = QueryParser.Parse(qry); } else { queryToAdd = ParseRawQuery(qry); } break; case Examineness.Escaped: //when an item is escaped it should be an exact match // http://examine.codeplex.com/workitem/10359 //standard query ... no query parser var stdQuery = fieldName + ":" + fieldValue.Value; queryToAdd = ParseRawQuery(stdQuery); break; case Examineness.Explicit: default: if (useQueryParser) { queryToAdd = this.QueryParser.GetFieldQuery(fieldName, fieldValue.Value); } else { //standard query var proxQuery = fieldName + ":" + fieldValue.Value; queryToAdd = ParseRawQuery(proxQuery); } break; } return queryToAdd; }
public IBooleanOperation Field(string fieldName, IExamineValue fieldValue) { Enforcer.ArgumentNotNull(fieldName, "fieldName"); Enforcer.ArgumentNotNull(fieldValue, "fieldValue"); return this.FieldInternal(fieldName, fieldValue, _occurance); }
public IBooleanOperation Field(string fieldName, IExamineValue fieldValue) => FieldInternal(fieldName, fieldValue, Occurrence);
protected internal BooleanQuery GetMultiFieldQuery( string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance, bool matchAllCombinations = false) { var qry = new BooleanQuery(); if (matchAllCombinations) { foreach (var f in fields) { foreach (var val in fieldVals) { var q = GetFieldInternalQuery(f, val, true); if (q != null) { qry.Add(q, occurance); } } } } else { var queryVals = new IExamineValue[fields.Length]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) queryVals[i] = fieldVals[0]; } else { queryVals = fieldVals; } for (int i = 0; i < fields.Length; i++) { var q = GetFieldInternalQuery(fields[i], queryVals[i], true); if (q != null) { qry.Add(q, occurance); } } } return qry; }
internal protected IBooleanOperation NodeTypeAliasInternal(IExamineValue examineValue, BooleanClause.Occur occurance) { //force lower case var eVal = new ExamineValue(examineValue.Examineness, examineValue.Value.ToLower(), examineValue.Level); //don't use the query parser for this operation, it needs to match exact return this.FieldInternal(NodeTypeAliasField, eVal, occurance, false); }
protected internal IBooleanOperation GroupedFlexibleInternal(string[] fields, BooleanOperation[] operations, IExamineValue[] fieldVals, BooleanClause.Occur occurance) { //if there's only 1 query text we want to build up a string like this: //(field1:query field2:query field3:query) //but Lucene will bork if you provide an array of length 1 (which is != to the field length) var flags = new BooleanClause.Occur[operations.Count()]; for (int i = 0; i < flags.Length; i++) flags[i] = operations.ElementAt(i).ToLuceneOccurance(); var queryVals = new IExamineValue[fields.Length]; if (fieldVals.Length == 1) { for (int i = 0; i < queryVals.Length; i++) queryVals[i] = fieldVals[0]; } else { queryVals = fieldVals; } var qry = new BooleanQuery(); for (int i = 0; i < fields.Length; i++) { var q = GetFieldInternalQuery(fields[i], queryVals[i], true); if (q != null) { qry.Add(q, flags[i]); } } this.Query.Add(qry, occurance); return new LuceneBooleanOperation(this); }
protected internal IBooleanOperation FieldInternal(string fieldName, IExamineValue fieldValue, BooleanClause.Occur occurance) { return(FieldInternal(fieldName, fieldValue, occurance, true)); }
internal protected IBooleanOperation NodeNameInternal(IExamineValue examineValue, BooleanClause.Occur occurance) { return this.FieldInternal(NodeNameField, examineValue, occurance); }
/// <summary> /// Returns the Lucene query object for a field given an IExamineValue /// </summary> /// <param name="fieldName"></param> /// <param name="fieldValue"></param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> internal protected Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue) { Query queryToAdd; switch (fieldValue.Examineness) { case Examineness.Fuzzy: queryToAdd = this.queryParser.GetFuzzyQuery(fieldName, fieldValue.Value, fieldValue.Level); break; case Examineness.SimpleWildcard: case Examineness.ComplexWildcard: queryToAdd = this.queryParser.GetWildcardQuery(fieldName, fieldValue.Value); break; case Examineness.Boosted: queryToAdd = this.queryParser.GetFieldQuery(fieldName, fieldValue.Value); queryToAdd.SetBoost(fieldValue.Level); break; case Examineness.Proximity: //This is how you are supposed to do this based on this doc here: //http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/spans/package-summary.html#package_description //but i think that lucene.net has an issue with it's internal parser since it parses to a very strange query //we'll just manually make it instead below //var spans = new List<SpanQuery>(); //foreach (var s in fieldValue.Value.Split(' ')) //{ // spans.Add(new SpanTermQuery(new Term(fieldName, s))); //} //queryToAdd = new SpanNearQuery(spans.ToArray(), Convert.ToInt32(fieldValue.Level), true); var proxQuery = fieldName + ":\"" + fieldValue.Value + "\"~" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = queryParser.Parse(proxQuery); break; case Examineness.Explicit: default: queryToAdd = this.queryParser.GetFieldQuery(fieldName, fieldValue.Value); break; } return queryToAdd; }
/// <summary> /// Query on the NodeTypeAlias /// </summary> /// <param name="nodeTypeAlias">The node type alias.</param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias) { return(this.search.NodeTypeAliasInternal(nodeTypeAlias, occurance)); }
/// <summary> /// Query method to search on node name /// </summary> /// <param name="query"></param> /// <param name="nodeName"></param> /// <returns></returns> public static IBooleanOperation NodeName(this IQuery query, IExamineValue nodeName) { var fieldQuery = query.Field("nodeName", nodeName); return(fieldQuery); }
/// <summary> /// Query documents with the specified field and culture /// </summary> public static INestedBooleanOperation Field(this INestedQuery query, string fieldName, string fieldCulture, IExamineValue fieldValue) { var cultureField = GetFieldName(fieldName, fieldCulture); return(query.Field(cultureField, fieldValue)); }
/// <summary> /// Query on the NodeName /// </summary> /// <param name="nodeName">Name of the node.</param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> public IBooleanOperation NodeName(IExamineValue nodeName) { return this.search.NodeNameInternal(nodeName, occurance); }
public IBooleanOperation NodeName(IExamineValue nodeName) { return(this.SearchCriteria.NodeName(nodeName)); }
/// <summary> /// Query on the specified field /// </summary> /// <param name="fieldName">Name of the field.</param> /// <param name="fieldValue">The field value.</param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> public IBooleanOperation Field(string fieldName, IExamineValue fieldValue) { return this.search.FieldInternal(fieldName, fieldValue, occurance); }
public IBooleanOperation NodeName(IExamineValue nodeName) { Enforcer.ArgumentNotNull(nodeName, "nodeName"); return this.NodeNameInternal(nodeName, _occurance); }
internal protected IBooleanOperation NodeTypeAliasInternal(IExamineValue examineValue, BooleanClause.Occur occurance) { return this.FieldInternal("nodeTypeAlias", examineValue, occurance); }
INestedBooleanOperation INestedQuery.Field(string fieldName, IExamineValue fieldValue) => _search.FieldInternal(fieldName, fieldValue, _occurrence);
private Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue, bool useQueryParser) { Query queryToAdd; switch (fieldValue.Examineness) { case Examineness.Fuzzy: if (useQueryParser) { queryToAdd = _queryParser.GetFuzzyQueryInternal(fieldName, fieldValue.Value.Replace("-", "\\-"), fieldValue.Level); } else { //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Fuzzy%20Searches var proxQuery = fieldName + ":" + fieldValue.Value.Replace("-", "\\-") + "~" + Convert.ToInt32(fieldValue.Level); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.SimpleWildcard: case Examineness.ComplexWildcard: if (useQueryParser) { queryToAdd = _queryParser.GetWildcardQueryInternal(fieldName, fieldValue.Value.Replace("-", "\\-")); } else { //this will already have a * or a . suffixed based on the extension methods //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Wildcard%20Searches var proxQuery = fieldName + ":" + fieldValue.Value.Replace("-", "\\-"); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.Boosted: if (useQueryParser) { queryToAdd = _queryParser.GetFieldQueryInternal(fieldName, fieldValue.Value.Replace("-", "\\-")); queryToAdd.Boost = fieldValue.Level; } else { //REFERENCE: http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boosting%20a%20Term var proxQuery = fieldName + ":\"" + fieldValue.Value.Replace("-", "\\-") + "\"^" + Convert.ToInt32(fieldValue.Level).ToString(); queryToAdd = ParseRawQuery(proxQuery); } break; case Examineness.Proximity: //This is how you are supposed to do this based on this doc here: //http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/spans/package-summary.html#package_description //but i think that lucene.net has an issue with it's internal parser since it parses to a very strange query //we'll just manually make it instead below //var spans = new List<SpanQuery>(); //foreach (var s in fieldValue.Value.Split(' ')) //{ // spans.Add(new SpanTermQuery(new Term(fieldName, s))); //} //queryToAdd = new SpanNearQuery(spans.ToArray(), Convert.ToInt32(fieldValue.Level), true); var qry = fieldName + ":\"" + fieldValue.Value.Replace("-", "\\-") + "\"~" + Convert.ToInt32(fieldValue.Level); if (useQueryParser) { queryToAdd = _queryParser.Parse(qry); } else { queryToAdd = ParseRawQuery(qry); } break; case Examineness.Escaped: //This uses the KeywordAnalyzer to parse the 'phrase' var stdQuery = fieldName + ":" + fieldValue.Value.Replace("-", "\\-"); //NOTE: We used to just use this but it's more accurate/exact with the below usage of phrase query //queryToAdd = ParseRawQuery(stdQuery); //This uses the PhraseQuery to parse the phrase, the results seem identical queryToAdd = ParseRawQuery(fieldName, fieldValue.Value.Replace("-", "\\-")); break; case Examineness.Explicit: default: if (useQueryParser) { queryToAdd = _queryParser.GetFieldQueryInternal(fieldName, fieldValue.Value.Replace("-", "\\-")); } else { //standard query var proxQuery = fieldName + ":" + fieldValue.Value.Replace("-", "\\-"); queryToAdd = ParseRawQuery(proxQuery); } break; } return(queryToAdd); }
public IBooleanOperation Field(string fieldName, IExamineValue fieldValue) { Enforcer.ArgumentNotNull(fieldName, "fieldName"); Enforcer.ArgumentNotNull(fieldValue, "fieldValue"); return(this.FieldInternal(fieldName, fieldValue, _occurance)); }
/// <summary> /// Query on the NodeName /// </summary> /// <param name="nodeName">Name of the node.</param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> public IBooleanOperation NodeName(IExamineValue nodeName) { return(this.search.NodeNameInternal(nodeName, occurance)); }
public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias) { Enforcer.ArgumentNotNull(nodeTypeAlias, "nodeTypeAlias"); return this.NodeTypeAliasInternal(nodeTypeAlias, _occurance); }
/// <summary> /// Query on the specified field /// </summary> /// <param name="fieldName">Name of the field.</param> /// <param name="fieldValue">The field value.</param> /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns> public IBooleanOperation Field(string fieldName, IExamineValue fieldValue) { return(this.search.FieldInternal(fieldName, fieldValue, occurance)); }
public IBooleanOperation NodeName(IExamineValue nodeName) { Enforcer.ArgumentNotNull(nodeName, "nodeName"); return(this.NodeNameInternal(nodeName, _occurance)); }
public IBooleanOperation Field(string fieldName, IExamineValue fieldValue) { return(this.SearchCriteria.Field(fieldName, fieldValue)); }
protected internal IBooleanOperation NodeNameInternal(IExamineValue examineValue, BooleanClause.Occur occurance) { return(this.FieldInternal(NodeNameField, examineValue, occurance)); }
public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias) { return(this.SearchCriteria.NodeTypeAlias(nodeTypeAlias)); }
public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias) { Enforcer.ArgumentNotNull(nodeTypeAlias, "nodeTypeAlias"); return(this.NodeTypeAliasInternal(nodeTypeAlias, _occurance)); }