예제 #1
0
        public Result <ContentItem> Search(N2.Persistence.Search.Query query)
        {
            if (!query.IsValid())
            {
                return(Result <ContentItem> .Empty);
            }

            var result = Request("POST", instanceName, query.ToJson());

            var lightweightResult = new JavaScriptSerializer().Deserialize <Result <LightweightHitData> >(result);

            return(new Result <ContentItem>
            {
                Count = lightweightResult.Count,
                Total = lightweightResult.Total,
                Hits = lightweightResult.Hits.Select(h =>
                                                     new LazyHit <ContentItem>
                {
                    Score = h.Score,
                    Title = h.Title,
                    Url = h.Url,
                    ID = h.Content.ID,
                    ContentAccessor = persister.Get
                }).ToList()
            });
        }
예제 #2
0
 public Result Search(Query query)
 {
     var result = new Result();
     int total;
     result.Hits = Search(query.Ancestor, query.Text, query.SkipHits, query.TakeHits, out total).Select(i => new Hit { Content = i, Score = i.Title.ToLower().Contains(query.Text.ToLower()) ? 1 : .5 });
     result.Total = total;
     return result;
 }
예제 #3
0
		public void OrOr_And()
		{
			indexer.Update(root);
			var first = CreateOneItem<PersistableItem2>(0, "some other page", root);
			indexer.Update(first);
			var second = CreateOneItem<PersistableItem2>(0, "some other stuff", root);
			indexer.Update(second);

			var searcher = new LuceneSearcher(accessor, persister);
			// TODO: support this
			//var query = (Query.For("some") | Query.For("other"))
			//    .Below(first);
			var query = new Query { Ancestor = first, Intersection = Query.For("some") | Query.For("other") };

			var result = searcher.Search(query);

			result.Hits.Count().ShouldBe(1);
			result.Hits.Any(h => h.Content == second).ShouldBe(false);
		}
예제 #4
0
파일: Query.cs 프로젝트: Jobu/n2cms
 public Query Or(Query orQuery)
 {
     if (Union != null)
         orQuery.Union = Union;
     Union = orQuery;
     return this;
 }
예제 #5
0
파일: Query.cs 프로젝트: Jobu/n2cms
 public Query Except(Query excludeQuery)
 {
     if (Exclution != null)
         excludeQuery.Or(Exclution);
     Exclution = excludeQuery;
     return this;
 }
예제 #6
0
파일: Query.cs 프로젝트: Jobu/n2cms
 public Query And(Query andQuery)
 {
     if (Intersection != null)
         andQuery.Intersection = Intersection;
     Intersection = andQuery;
     return this;
 }