Developer forum

Forum » Development » Index query for id with no dots

Index query for id with no dots

Mikkel Toustrup Olsen
Reply

Hi all,

I'm pretty new to the lucene indexing and what mechanics lies behind it.

However, I currently have a product index containig all kinds of data and a freetext search which works fine.

However, as the productid's contains dot like : "0010.2000", the customer is interested in the search returning results whenever you type or maybe even better copy paste an id with no dots to the query like : "00102000" .. 

Any suggestions on how to solve this puzzle?

BR Mikkel


Replies

 
Nicolai Pedersen
Reply

Hi Mikkel

You need to index the data for it I think. You can create something like this:

 

namespace Dynamicweb.Ecommerce.Examples
{
    class IndexBuilderExtenderExample : IndexBuilderExtenderBase<ProductIndexBuilder>
    {
        public override void ExtendDocument(IndexDocument document)
        {
            if (document.ContainsKey("ProductNumber"))
            {
                string productNumber = (string)document["ProductNumber"];
                document.Add("ProductNumberCleaned", productNumber.Replace(".", string.Empty));
            }
        }
    }
}

BR Nicolai

 

 
Mikkel Toustrup Olsen
Reply

Hi Nicolai,

Great, i'll give it a go and give an update whenever - thanks :-)

BR Mikkel

 

You must be logged in to post in the forum