public override Query GetQuery() { if (string.IsNullOrWhiteSpace(_queryString)) { return(new EmptyQuery()); } var parser = new MultiFieldQueryParser(QueryUtils.GetQueryStrings(typeof(T)), _analyzer); var queryString = QueryParser.Escape(_queryString); return(parser.Parse(queryString)); }
protected virtual List <T> HitsToContract <T>(SearchResult hits) where T : class, new() { var result = new List <T>(); var queryStrings = QueryUtils.GetQueryStrings(typeof(T)); for (int i = 0; i < hits.TotalHits; i++) { Assembly assembly = Assembly.GetAssembly(typeof(T)); T obj = assembly.CreateInstance(String.Join(".", new[] { typeof(T).Namespace, typeof(T).Name })) as T; foreach (PropertyInfo property in obj.GetType().GetProperties()) { if (queryStrings.Contains(property.Name) && property.CanWrite) { obj.SetValue(property, hits.Docs[i].Get(property.Name)); } } result.Add(obj); } return(result); }
public void should_get_queryStrings() { var queryStrings = QueryUtils.GetQueryStrings(typeof(SpaceObject)); Assert.IsTrue(queryStrings.Contains("Name")); }