Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

GROVE-334 : adds 'show more' link to show more facets in the Vue template #9

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions routes/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ router.use(
})
);

router.use(
'/search/similar',
routeFactory.defaultSearchRoute({
authProvider: authProvider,
namedOptions: 'similar', // default: 'all'
// options: {
// Add JSON search options here.
// default: none
// WARNING: This will override the saved search options referenced by 'namedOptions' above.
// Example for making result labels using name property of person sample-data
// 'extract-document-data': {
// 'extract-path': ['/name']
// }
// },
idConverter: idConverter, // default: encodeURIComponent(result.uri)
makeLabel: result => {
// default: none
return (
result.extracted &&
result.extracted.content[0] &&
result.extracted.content[0].name
);
}
})
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long, but after rethinking about this, I am thinking we should not need a separate /search/similar endpoint. Instead, similar should just be 'yet another constraint' in the existing all.xml. Could you revisit this PR (you will have to open a new one unfortunately), and move that custom constraint into all.xml?

https://github.com/marklogic-community/grove-ml-gradle/pull/3/files

// Provide CRUD route for pseudo-type 'all'
router.use(
'/crud/' + type,
Expand Down
10 changes: 10 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ if (enableLegacyProxy) {
endpoint: '/resources/extsimilar',
methods: ['get'],
authed: true
},
{
endpoint: '/values/*',
methods: ['get', 'post'],
authed: true
},
{
endpoint: '/config/query/all', // NOTE: allows get on all extensions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows getting the 'all' search options..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice if we would expose proper rest endpoints for both of these. so, maybe /search/all/config for the latter, and /search/all/values for the first. It might be possible to leverage this work to rewrite those calls to other urls against ML: #29

From top of my head, something like:

route.use('/search/' + type, routeFactory.defaultExtensionRoute({
    authProvider,
    actions: {
        config: {
            uri: '/v1/config/query/all',
            GET: function(body, params, req){
                return {
                    method: req.method,
                    body: '',
                    params: {}
                }
            }
        }
    }

It may be necessary to patch either the default search or default ext route to fall through, otherwise one or the other might not get reached..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have a play with that @janmichaelyu ?

methods: ['get'],
authed: true
}
// TODO: move this to visjs documentation for visjs-graph
// Other possibilities:
Expand Down