Developer forum

Forum » Swift » Using the new search in swift for pages not products.

Using the new search in swift for pages not products.

Daniel Hollmann
Reply

Hi DW.

 

I have to create a page for a customer that does not have any products, but a lot of content pages.
I have tried to examine the new search functions with typeahead in Swift, and it seams that this search only will work with products and a product list out of the gate. https://doc.dynamicweb.com/swift/customization#sideNavTitle1-6-6


I tried to just switch out the query, with something that returned pages and not products, but since the searchpage by default uses the app Product catalog for ViewModel that looks for products by, I’m thinking that the functionality is not really set up for pages.
So my question is, - is it possible customize the search to work with pages, without having to rewrite too much, of an already working search function with type ahead, and other functionality.

Best regards
Daniel


Replies

 
Nicolai Pedersen
Reply

Hi Daniel

Yes it is - and sorry we do not have that yet!

  1. Setup a content index: https://doc.dynamicweb.com/documentation-9/indexing/indexing-search/indexes#4778
  2. Create a content query based on the above index. You can use more or less the same setup as Rapido have.
  3. On the page where the search suggestions come from, disable the product catalog paragraph and insert a paragraph with the QueryPublisher module: https://doc.dynamicweb.com/documentation-9/indexing/apps/query-publisher
  4. On this paragraph, select a field from the index (probably a free text field that you create) for the spell suggestion feature.
  5. Create a template (based on the product list template from the disabled paragraph) and return the same kind of results.

It will take a bit of sherlock holmes to get going, but doable.

BR Nicolai

 
Daniel Hollmann
Reply

Thanks for your answer! I will try to do it this way. I will write here agian if I am successful and my possible obstacles!

 
Christoffer Rosendahl Frede
Reply

Hello.

I have setup a content index and a query publisher and setup a free text search and it seems to be working fine with page properties. however it would be nice if we couid configure the free text, on specific swift paragraph fields for example Property_Swift_Text_Text or similar, i have tested it and it does not seem to work. as a workaround, i used the properties "Page items content" and "Paragrap content" which gets everything in one big pile, as i understand it. i have checked the templateTags of the QueryResultItem  and it does not seem to have any references to the swift paragraph properties. am i missing something or this not supported ?

screendump of free text field setup:

Best regards Christoffer

 
Nicolai Pedersen
Reply

Hi Christoffer

When you use the querypublisher, only fields that are marked as stored, can be rendered.

Page items content and paragraph content fields cannot be rendered I think.

On the index you also have fields with paragraph and page id. You can get those ids in the template, and then you have to use Dynamicweb.Services.Pages/Paragraphs to get hold of the actual instances and do whatever you need from there.

BR Nicolai

 

You must be logged in to post in the forum