public void testSearchByANDBadFromPortal()
            {
                ElasticDocument document = new ElasticDocument();
                document.Search.Owner = "garcia";
                document.Search.Name = "accxount";

                SearchCriteria criteria = new SearchCriteria(SHOULD, MATCH);
                var results = myEngine.Search(document, criteria);

                Assert.AreEqual(0, results.Count());
            }
            public void testSearchByNameHitWeirdFromPortal()
            {
                ElasticDocument document = new ElasticDocument();
                document.Search.Owner = "Dagmar  garccia";
                document.Search.Name = "juan";

                SearchCriteria criteria = new SearchCriteria(SHOULD, MATCH);
                var results = myEngine.Search(document, criteria);

                Assert.AreEqual(0, results.Count());
            }
            public void testSearchByANDFoundFromPortal()
            {
                ElasticDocument document = new ElasticDocument();
                document.Search.Owner = "adm_phillipe";
                document.Search.Name = "Sound Device";

                SearchCriteria criteria = new SearchCriteria(SHOULD, MATCH);
                var results = myEngine.Search(document, criteria);

                Assert.AreEqual(1, results.Count());
            }
        public void testSearchByNameOwnerMustNoResult()
        {
            ElasticDocument document = new ElasticDocument();
            document.Search.Name = "Contract Affiliate";
            document.Search.Owner = "adm_phillipe";

            SearchCriteria criteria = new SearchCriteria(MUST, MATCH);
            var results = myEngine.Search(document, criteria);

            Assert.AreEqual(0, results.Count());

        }  
            public void testSearchByNameFromPortal()
            {
                ElasticDocument document = new ElasticDocument();
                document.Search.Name = "Group Grouping Subreport";
                document.Search.Owner = "CITRITE\\adm_phillipe";

                SearchCriteria criteria = new SearchCriteria(SHOULD, MATCH);
                var results = myEngine.Search(document, criteria);
                
                foreach(var e in results)
                    Debug.WriteLine(e.ToString());

                Assert.AreEqual(10993, results.Count());
            }
Example #6
0
        private bool UpdateFromSSRS()
        {
            ElasticDocument document = new ElasticDocument();
            String idItemSSRSUrl; 
            var itemsCatalog = GetAllCatalogSSRS();

            document.Index = SSRS;

            foreach(var itemCatalog in itemsCatalog)
            {
                document.Type = itemCatalog.ID;
                var items = GetCatalogItems(itemCatalog.Path);

                if (items!=null)
                {
                    foreach (var item in items)
                    {
                        document.Search.Name = item.Name;
                        document.Search.Description = item.Description;
                        document.Search.Owner = item.CreatedBy;

                        idItemSSRSUrl = SEPARATOR_URL + itemCatalog.Name + SEPARATOR_URL + item.Name;
                        document.Url = HEADER_SSRS_URL + idItemSSRSUrl;
                        document.Id = item.ID;

                        var docToElastic = ConvertDocToElastic(document);

                        var result = PostClientIndex(document.Index, document.Type, document.Id, docToElastic);

                    }
                }
            }

            return true;
        }
        public void testSearchByNameSM()
        {                        
            ElasticDocument document = new ElasticDocument();
            document.Search.Name = "Worldwide Touchpoints";

            SearchCriteria criteria = new SearchCriteria(SHOULD, MATCH);
            var results = myEngine.Search(document, criteria);

            Assert.AreEqual(2, results.Count());
            
        }
Example #8
0
        private Object ConvertDocToElastic(ElasticDocument document)
        {
            var result = new
                        {
                            _search = new
                            {
                                name = document.Search.Name,
                                description = document.Search.Description,
                                owner = document.Search.Owner
                            },

                            _body = new {
                                name = document.Search.Name,
                                description = document.Search.Description,
                                owner = document.Search.Owner
                            },

                            _url = document.Url
                        };

            return result;
        }
Example #9
0
        private bool UpdateFromSharePoint()
        {
            ElasticDocument document = new ElasticDocument();
            String idItemCitroUrl, headerItemUrl;            
            //CamlQuery camlQuery = new CamlQuery();
            CamlQuery camlQuery = CamlQuery.CreateAllItemsQuery();
            //camlQuery.ViewXml = "<View/>";

            ListCollection itemsCitro = GetAllCitropediaLists();
            //List itemsBi = items.GetByTitle("BI Terms");
            ListItemCollection listItems;

            document.Index = CITROPEDIA;           	 
 
            foreach (List itemList in itemsCitro)
            {
                if (IsBiTerm(itemList.Title))
                {
                    listItems = itemList.GetItems(camlQuery);
                    clientContextSharePoint.Load(listItems);

                    clientContextSharePoint.Load(listItems,
                        items=> items.Include(
                        item=>item.ContentType,
                        item=>item.ContentType.Name));

                    clientContextSharePoint.ExecuteQuery();

                    document.Type = itemList.Id.ToString();
                    headerItemUrl = HEADER_SP_URL + "List=" + document.Type;

                    foreach (var item in listItems)
                    {
                        var v_name = item.FieldValues.Where(entry => entry.Key.ToLower().Contains(TITLE)).First().Value;
                        var v_description = item.FieldValues.Where(entry => entry.Key.ToLower().Contains(DESCRIPTION)).First().Value;
                        var dd = item.FieldValues.Where(entry => entry.Key.ToLower().Contains(OWNER));
                        var v_owner = item.FieldValues.Where(entry => entry.Key.ToLower().Contains(OWNER)).First().Value;

                        if (v_name != null)
                            document.Search.Name = v_name.ToString();
                        else
                            document.Search.Name = SPACE;

                        if (v_description != null)
                            document.Search.Description = v_description.ToString();
                        else
                            document.Search.Description = SPACE;

                        if (v_owner != null)
                            document.Search.Owner = v_owner.ToString();
                        else
                            document.Search.Owner = SPACE;

                        idItemCitroUrl = "&ID=" + item.Id + "&ContentTypeId=" + item.ContentType.Id.ToString();
                        document.Url = HEADER_SP_URL + idItemCitroUrl;
                        document.Id = item.Id.ToString();

                        var docToElastic = ConvertDocToElastic(document);

                        var result = PostClientIndex(document.Index, document.Type, document.Id, docToElastic);
                    }
                }

            }

            return true;
        }
Example #10
0
        private String GenerateDocumentUri(ElasticDocument objectToSearch, String unionSearch)
        {
            String document = null;

            if (CheckSearchValue(objectToSearch.Search.Name))
                document = NAME + DP + objectToSearch.Search.Name.Trim() + unionSearch;

            if (CheckSearchValue(objectToSearch.Search.Description))
                document = document + DESCRIPTION + DP + objectToSearch.Search.Description.Trim();

            if (CheckSearchValue(objectToSearch.Search.Owner))
                document = document + OWNER + DP + objectToSearch.Search.Owner.Trim();
            
            return document;
        }
Example #11
0
 private String GetMyFuzzyText(ElasticDocument doc)
 {
     return doc.Search.Name + SPACE + doc.Search.Description + SPACE + doc.Search.Owner;
 }
Example #12
0
        public ElasticsearchDynamicValue[] Search(ElasticDocument objectToSearch, SearchCriteria p_criteria)
        //public IEnumerable<ElasticDocument> Search(ElasticDocument objectToSearch)
        {
            ElasticsearchDynamicValue[] response = null;
            QueryContainer queryContainer = new QueryContainer();

           /*
            var queryMatchName = new MatchQueryDescriptor<ElasticDocument>().OnField("_search.name").Query(objectToSearch.Search.Name);
            var queryMatchDescription = new MatchQueryDescriptor<ElasticDocument>().OnField("_search.description").Query(objectToSearch.Search.Description);
            var queryMatchOwner = new MatchQueryDescriptor<ElasticDocument>().OnField("_search.owner").Query(objectToSearch.Search.Owner);

            var queryTermName = new TermQueryDescriptor<ElasticDocument>().OnField("_search.name").Value(objectToSearch.Search.Name);
            var queryTermDescription = new TermQueryDescriptor<ElasticDocument>().OnField("_search.description").Value(objectToSearch.Search.Description);
            var queryTermOwner = new TermQueryDescriptor<ElasticDocument>().OnField("_search.owner").Value(objectToSearch.Search.Owner);
            */

            if (p_criteria.Condition.Equals(SHOULD) && p_criteria.QueryType.Equals(MATCH))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                            Should(s => s.Match(m => m.OnField("_search.name").Query(objectToSearch.Search.Name)) ||
                                        s.Match(m => m.OnField("_search.description").Query(objectToSearch.Search.Description)) ||
                                        s.Match(m => m.OnField("_search.owner").Query(objectToSearch.Search.Owner))));

            if (p_criteria.Condition.Equals(MUST) && p_criteria.QueryType.Equals(MATCH))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                            Must(s => s.Match(m => m.OnField("_search.name").Query(objectToSearch.Search.Name)) &&
                                      s.Match(m => m.OnField("_search.description").Query(objectToSearch.Search.Description)) &&
                                      s.Match(m => m.OnField("_search.owner").Query(objectToSearch.Search.Owner))));

            if (p_criteria.Condition.Equals(SHOULD) && p_criteria.QueryType.Equals(TERM))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                        Should(s => s.Term(m => m.OnField("_search.name").Value(objectToSearch.Search.Name)) ||
                                    s.Term(m => m.OnField("_search.description").Value(objectToSearch.Search.Description)) ||
                                    s.Term(m => m.OnField("_search.owner").Value(objectToSearch.Search.Owner))));

            if (p_criteria.Condition.Equals(MUST) && p_criteria.QueryType.Equals(TERM))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                            Must(s => s.Term(m => m.OnField("_search.name").Value(objectToSearch.Search.Name)) &&
                                      s.Term(m => m.OnField("_search.description").Value(objectToSearch.Search.Description)) &&
                                      s.Term(m => m.OnField("_search.owner").Value(objectToSearch.Search.Owner))));
            
            var searchDescriptor = new SearchDescriptor<ElasticDocument>().
                Query(queryContainer);

            var request = clientElasticNest.Serializer.Serialize(searchDescriptor);

            var results = clientElasticNest.Raw.Search(request);

            int total_hits = (int)results.Response[HITS][TOTAL_HITS];
            ElasticsearchDynamicValue hits = results.Response[HITS][HITS];

            if (total_hits > 0)
                response = new ElasticsearchDynamicValue[total_hits];
            else
                response = new ElasticsearchDynamicValue[0];

            for (int i = 0; i < total_hits; i++)
            {
                response[i] = hits[i];
            }

            return response;
            
        }