microsoft-search / pnp-modern-search

Home of PnP Modern Search solutions, helping you move from classic to modern SharePoint and beyond
https://microsoft-search.github.io/pnp-modern-search
Other
378 stars 331 forks source link

Query Template for Microsoft Search #1467

Closed edarroudi closed 2 years ago

edarroudi commented 2 years ago

Is your feature request related to a problem? Please describe. I need to be able to add a prefilter to the Search Results webpart. This is possible for the SharePoint search with the "Query template" property but not for the Microsoft Search data source.

Describe the solution you'd like It would be nice to add the query template property for Microsoft Search data source as well. image I did develop this myself and it works fine.

Describe alternatives you've considered Using filters wouldn't work, i thought of a custom searchbox component that sends the modified query to the search results webpart but that doesn't make any sense.

Additional context I have a task to modify & add some additional features to the modern search webparts. I consider some of the modifications as "too company specific" but some of the changes could be of use for the global community. How should i approach this, a) upload a list of possible features and you vote which ones can be implemented by me (maybe with some modifications) or b) just create pull requests and you have a look at those modifications?

FranckyC commented 2 years ago

Hi @edarroudi , unfortunately, there is no query template option for the Microsoft Search API for now. We can't do much about that :/. For the features you want to add, please describe them in 'Ideas' section in the discussions tab https://github.com/microsoft-search/pnp-modern-search/discussions/categories/ideas.

edarroudi commented 2 years ago

Hi @edarroudi , unfortunately, there is no query template option for the Microsoft Search API for now. We can't do much about that :/. For the features you want to add, please describe them in 'Ideas' section in the discussions tab https://github.com/microsoft-search/pnp-modern-search/discussions/categories/ideas.

hey @FranckyC , Thank you for your reply. I actually don’t specifically need a querytemplate but just a way to enhance /modify the user query as shown in my screenshot. I modified the code and just pass it in the query string and that works fine. Would that be a bad feature? I don’t see an issue here.

wobba commented 2 years ago

@edarroudi I think that makes sense. Have the option to specify additional KQL in the web part which is appended to the user query.

edarroudi commented 2 years ago

Hey @wobba , thanks. As i already coded that (have to refactor it a bit), is it ok for me to create a pull request? I'm new to this kind of community driven coding so sorry for any stupid questions. Would you need some specific naming for the label? I used the label Query Template but maybe the naming will cause some misunderstanding. How about "KQL Query modifier"?

Also on another topic: I see that in /searchparts/.gitignore you have the package-lock.json added but not in /search-extensibility . Any reason for that? I usually keep package-lock.json in the respository as mostly everyone uses npm ci instead of npm i.

I will add now several feature requests and discussions to the discussion board as @FranckyC suggested.

Thank you all for your work!

wobba commented 2 years ago

We'll take a look at the PR

FranckyC commented 2 years ago

@wobba let me check the PR as well before merging, Thanks!

edarroudi commented 2 years ago

included in (develop) - December release

wobba commented 2 years ago

@FranckyC I see "queryTemplate" now working in the v1.0 endpoint for graph, so we could do a generic implementation targeting that field for both SP and Graph providers. It likely won't support all tokens, but that's ok as we replace many of them client side.

Ami99049 commented 11 months ago

Is custom query template condition working in Microsoft search as data source

wobba commented 11 months ago

@Ami99049 reading the official documentation is the way to go :) https://learn.microsoft.com/en-us/graph/search-concept-query-template and we use this when crafting the query. That said, queryText + template is concatenated anyways for the actual query.