Beispiel #1
0
        private void IndexDocuments(JArray documents, IList <string> searchableFields)
        {
            foreach (var document in documents)
            {
                var uid = document.Value <string>(_uidFieldName);
                foreach (var searchableField in searchableFields)
                {
                    var fieldValues = GetFieldValue(document, searchableField);
                    if (fieldValues != null && fieldValues.Count > 0)
                    {
                        foreach (var fieldValue in fieldValues)
                        {
                            var fieldTokens = Tokenizer.Tokenize(TokenSantizer.Sanitize(fieldValue));
                            foreach (var fieldToken in fieldTokens)
                            {
                                var expandedTokens = IndexStrategy.ExpandToken(fieldToken);
                                foreach (var expandToken in expandedTokens)
                                {
                                    SearchIndex.IndexDocument(expandToken, uid, document);
                                }
                            }
                        }
                    }
                }
            }

            _initialized = true;
        }
Beispiel #2
0
        public JArray Search(string query)
        {
            var tokens = Tokenizer.Tokenize(TokenSantizer.Sanitize(query));

            return(SearchIndex.Search(tokens, Documents));
        }