public ElasticSearchBooleanOperation ManagedQueryInternal(string query, string[] fields = null) { Query.Add(new LateBoundQuery(() => { //if no fields are specified then use all fields fields = fields ?? AllFields; //Strangely we need an inner and outer query. If we don't do this then the lucene syntax returned is incorrect //since it doesn't wrap in parenthesis properly. I'm unsure if this is a lucene issue (assume so) since that is what //is producing the resulting lucene string syntax. It might not be needed internally within Lucene since it's an object //so it might be the ToString() that is the issue. var outer = new BooleanQuery(); var inner = new BooleanQuery(); var fielddefintion = _searcher.AllProperties.Values.Where(x => x.Type == "text").Select(x => x.Name.Name); foreach (var field in fielddefintion) { var q = FullTextType.GenerateQuery(field, query, DefaultAnalyzer); if (q != null) { //CriteriaContext.ManagedQueries.Add(new KeyValuePair<IIndexFieldValueType, Query>(type, q)); inner.Add(q, Occur.SHOULD); } } outer.Add(inner, Occur.SHOULD); return(outer); }), Occurrence); return(new ElasticSearchBooleanOperation(this)); }
protected override INestedBooleanOperation ManagedQueryNested(string query, string[] fields = null) { //TODO: Instead of AllFields here we should have a reference to the FieldDefinitionCollection var fielddefintion = _searcher.AllProperties.Values.Where(x => x.Type == "text").Select(x => x.Name.Name); foreach (var field in fields ?? fielddefintion) { var fullTextQuery = FullTextType.GenerateQuery(field, query, DefaultAnalyzer); Query.Add(fullTextQuery, Occurrence); } return(new ElasticSearchBooleanOperation(this)); }