Searching for Numbers in Smart Search

Andre Pfanz asked on August 19, 2016 15:52

I want to search blog posts hosted at Hubspot using the smart search. Each blog post has one or more topic IDs such as 4305550016. I created the custom index for it using the following code:

foreach (BlogPost blogPost in blogPosts)
{
    // Gets the text content of the blog post
    string text = blogPost.post_body;

    // Converts the text to lower case
    text = text.ToLowerCSafe();

    string topicIDs = "";
    foreach (object id in blogPost.topic_ids)
    {
        topicIDs += " ," + id;
    }

    text += topicIDs;

    // Removes diacritics
    text = TextHelper.RemoveDiacritics(text);
    System.DateTime publishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
    publishDate = publishDate.AddMilliseconds(long.Parse(blogPost.publish_date.ToString())).ToLocalTime();
    // Creates a new Lucene.Net search document for the current text file
    SearchDocumentParameters documentParameters = new SearchDocumentParameters()
    {
        Index = srchInfo,
        Type = SearchHelper.CUSTOM_SEARCH_INDEX,
        Id = Guid.NewGuid().ToString(),
        Created = publishDate
    };
    ISearchDocument doc = SearchHelper.CreateDocument(documentParameters);
    // Adds a content field. This field is processed when the search looks for matching results.
    doc.AddGeneralField(SearchFieldsConstants.CONTENT, text, SearchHelper.StoreContentField, true);

    ... 
    iw.AddDocument(doc);
}

The index builds. However, when I search for a topic ID in the search preview on the index maintenance section of Kentico, I don't get any results. I appreciate any suggestions.

Recent Answers


Chetan Sharma answered on August 20, 2016 16:46 (last edited on August 20, 2016 16:46)

You can download this utility called Luke to analyze the column fiels of your Lucene index. You can see what is their in the index and run queries to see what results can you expect.

A great tool.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.