{"_id":"@coveops/dynamic-query-facet-generator","_rev":"40-fa75afc9abe35e38826dfa6e6b0a1c03","name":"@coveops/dynamic-query-facet-generator","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@coveops/dynamic-query-facet-generator","version":"1.0.0","keywords":[],"author":"","license":"Apache-2.0","_id":"@coveops/dynamic-query-facet-generator@1.0.0","maintainers":[{"name":"eaubin","email":"eaubin@coveo.com"},{"name":"plavigueur","email":"plavigueur@coveo.com"},{"name":"elafleur_coveo","email":"elafleur@coveo.com"},{"name":"lgcarrierbedard","email":"lgcarrier@coveo.com"},{"name":"wnijmeijer","email":"wnijmeijer@coveo.com"},{"name":"hsinghcoveo","email":"hsingh@coveo.com"},{"name":"achouan","email":"achouan@coveo.com"},{"name":"jfallaire","email":"jeanfrancois.allaire@gmail.com"},{"name":"davebouffard","email":"dbouffard@coveo.com"},{"name":"jmdro","email":"jmdrolet@coveo.com"},{"name":"eqcoveo","email":"equinn@coveo.com"},{"name":"jfleurent","email":"jfleurent@coveo.com"},{"name":"mthusscoveo","email":"mthuss@coveo.com"},{"name":"sfecteau","email":"sfecteau@coveo.com"},{"name":"jwolfe-coveo","email":"jwolfe@coveo.com"},{"name":"rvundavalli","email":"rvundavalli@coveo.com"},{"name":"gfoumbi","email":"gfoumbi@coveo.com"},{"name":"yass1408","email":"yassine_lakhdar@hotmail.com"},{"name":"coveoit","email":"itaccounts@coveo.com"}],"homepage":"https://github.com/Coveo-Turbo/dynamic-query-facet-generator#readme","bugs":{"url":"https://github.com/Coveo-Turbo/dynamic-query-facet-generator/issues"},"dist":{"shasum":"1d6bf7ac5e42023796a8d565d7d0121b00f8707a","tarball":"https://registry.npmjs.org/@coveops/dynamic-query-facet-generator/-/dynamic-query-facet-generator-1.0.0.tgz","fileCount":8,"integrity":"sha512-L/597LKp+z7E1BHDg9b7glh9hlB6njr6GucxH6B91XM6UEiGGXfctcp6NlkQFgmbhEfTC2IOLs9GrPJRh/7xqg==","signatures":[{"sig":"MEQCIHIMXJemBpl7nF5wZdyuDHgUlHvkqvWkJhC/inUh6XuJAiBSly18rEm4sv34on9JsxiKd5uc48EskTE1Kfxo6iJixw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":70653,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfqqHPCRA9TVsSAnZWagAAOLkP+QDpp50xBZRp7VqvGBqk\n0zBHmW3o7slpFEvoS5nKYpbGW+RHwFQg5pBm37rDJwVOE5EqApwYGYhDm4VW\nxxXycMb7Q7JYgHBqnv9CB/EXFvq6KKyM1RJjn0/QpJW0WODgoOWpTQoGY3M+\nxftg0FTYQQBG+Hp1IPc/oI5DkuAHpAiCC44pYzWC2Vyp/Yep213UpYIB+Oso\nXCa0/CquTcdyFyi4dHQrarWwQfQEOBc3RwLGohpXpVnqxNOwbAbyznrwgh1l\nvhIq+EaJW6mwI6igLrQvPILexh5IM9/79aXS3ymGHKGFmDgESP/F8uhyb5Br\nFKHF7uA5CyNwVdj2lDNrU9qSzfUKZrMvbMSAtD1l0q961ssTe0kKOhSs1IjW\nm8eXjP75UELPgHUYbIxs6kFXEcCtvirIGStULw+9y8HwUCGmSaorml1mv55J\n3askRxdMqgv8J1sopmzRfJ3iXwqb+yeF+OIdn3ZoxDlivNx6Zyvaeg5ISkVb\n0mENFEzg0JzHC6ntfiMEzwl55uiJncnQvFT4LfOsKlbUoUJ52IhqXzi8pIAg\njQHuIAlnAgf8y/rYZ+XlwE5Yucx2DDtwmMjwyk7t/w9u9cQOUtlER/Nz+6y8\ncuRM9yBFRYcJ2LjrxIqw/f1hW7cnSAH9GIE+TdNtb6OQITi077UWeNVVPtck\nYudX\r\n=GiBN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"518c84f6f53a141731bae4fc6eac2ff12aeec8c4","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"coveops build DynamicQueryFacetGenerator --template typescript","serve":"coveops serve","watch":"coveops build DynamicQueryFacetGenerator --template typescript --watch","precompile":"npm run build"},"_npmUser":{"name":"wnijmeijer","email":"wnijmeijer@coveo.com"},"repository":{"url":"git+https://github.com/Coveo-Turbo/dynamic-query-facet-generator.git","type":"git"},"_npmVersion":"6.9.0","description":"Dynamically create Facets based upon a quick query","directories":{},"_nodeVersion":"10.16.0","dependencies":{"coveo-search-ui":"^2.9856.8","@coveops/turbo-core":"^1.1.1","@coveops/localization-manager":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@coveops/cli":"^0.13.2"},"_npmOperationalInternal":{"tmp":"tmp/dynamic-query-facet-generator_1.0.0_1605018063201_0.6336524624661417","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-11-10T14:21:02.930Z","modified":"2026-05-13T17:46:16.023Z","1.0.0":"2020-11-10T14:21:03.366Z"},"bugs":{"url":"https://github.com/Coveo-Turbo/dynamic-query-facet-generator/issues"},"license":"Apache-2.0","homepage":"https://github.com/Coveo-Turbo/dynamic-query-facet-generator#readme","keywords":[],"repository":{"url":"git+https://github.com/Coveo-Turbo/dynamic-query-facet-generator.git","type":"git"},"description":"Dynamically create Facets based upon a quick query","maintainers":[{"email":"jfleurent@coveo.com","name":"jfleurent"},{"email":"jmdrolet@coveo.com","name":"jmdro"},{"email":"jeanfrancois.allaire@gmail.com","name":"jfallaire"},{"email":"achouan@coveo.com","name":"achouan"},{"email":"lpblais@coveo.com","name":"lpblais-coveo"},{"email":"watallah@coveo.com","name":"watallah"},{"email":"eshahneh@coveo.com","name":"ehsanshahneh"},{"email":"belbizri@coveo.com","name":"belbizri"},{"email":"jpurohit@coveo.com","name":"jpurohit_coveo"},{"email":"acherney2@coveo.com","name":"acherney2c"},{"email":"jcharron@coveo.com","name":"jcharron-coveo"},{"email":"oa-npmcoveops@oacvo.com","name":"oa-npmcoveops"}],"readme":"# DynamicQueryFacetGenerator\r\n\r\nGenerates Facets dynamicaly based upon results from the index.\r\n\r\nFirst the fields from the current index are retrieved (so that the component knows which fields are facets).\r\nThese fields are stored in localstorage (so it only happens once a week).\r\n\r\nSecond when a query is being executed, the facet cache is checked. If the query is in the cache the facets will be retrieved from cache.\r\nIf not, then a query is being executed against the index. The first number of results are being examined for facet values. If the treshold is met, and the distinct values are bigger then 1, the facet is added to the UI.\r\n\r\nAnother possibility is to use a push source query. This means: you must have a push source with QUERY + FACETS in them. This gives a bit better performance.\r\n\r\nDisclaimer: This component was built by the community at large and is not an official Coveo JSUI Component. Use this component at your own risk.\r\n\r\n\r\n## Getting Started\r\n\r\n1. Install the component into your project.\r\n\r\n```\r\nnpm i @coveops/dynamic-query-facet-generator\r\n```\r\n\r\n2. Use the Component or extend it\r\n\r\nTypescript:\r\n\r\n```javascript\r\nimport { DynamicQueryFacetGenerator, IDynamicQueryFacetGeneratorOptions } from '@coveops/dynamic-query-facet-generator';\r\n```\r\n\r\nJavascript\r\n\r\n```javascript\r\nconst DynamicQueryFacetGenerator = require('@coveops/dynamic-query-facet-generator').DynamicQueryFacetGenerator;\r\n```\r\n\r\n3. You can also expose the component alongside other components being built in your project.\r\n\r\n```javascript\r\nexport * from '@coveops/dynamic-query-facet-generator'\r\n```\r\n\r\n4. Include the component in your template as follows:\r\n\r\nPlace the component in your markup:\r\n\r\n```html\r\n<div class=\"CoveoDynamicQueryFacetGenerator\"></div>\r\n```\r\n\r\n## Usage\r\n\r\nAdd the `CoveoDynamicQueryFacetGenerator` along with the rest of the Facets.\r\n\r\n```html\r\n<div class=\"coveo-facet-column\">\r\n  <div class=\"CoveoDynamicFacetManager\">\r\n    <div class=\"CoveoDynamicFacet\" data-field=\"@prd_brand\" data-title=\"Brand\"></div>\r\n    <div class=\"CoveoDynamicFacet\" data-field=\"@prd_category\" data-title=\"Category Type\"></div>\r\n    <div class=\"CoveoDynamicQueryFacetGenerator\" data-depends-on=\"@prd_category\"></div>\r\n  </div>\r\n</div>\r\n```\r\n\r\nBefore you initialize the UI, make sure you pass the facet fields dictionary to the DynamicQueryFacetGenerator component\r\n\r\n```javascript\r\ndocument.addEventListener('DOMContentLoaded', function () {\r\n  Coveo.SearchEndpoint.configureSampleEndpointV2();\r\n  Coveo.init(document.body, {\r\n    DynamicQueryFacetGenerator: {\r\n      dictionary: {\r\n        \"computer\": \"Computer Name\",\r\n        \"phone\": \"Phone\"\r\n      },\r\n      queryToExecute: \"@source==BBQs\",\r\n      noOfResults: 25\r\n    }\r\n  });\r\n})\r\n```\r\n\r\n### Transform\r\nThere is a public transform method available to transform the fieldname into a title.\r\n\r\n### Dictionary\r\nThe dictionary is used to transform the field name into a proper title.\r\n\r\n### Blacklist\r\nIf certain facets should never be shown. Add them to the blacklist.\r\n\r\n\r\n## Options\r\n\r\nThe following options can be configured:\r\n\r\n| Option | Required | Type | Default | Notes |\r\n| --- | --- | --- | --- | --- |\r\n| `queryToExecute` | No | string | `` | Query to execute to fetch the facet values. |\r\n| `noOfResults` | No | number | `15` | How many results must be examines when checking for facet values. Recommendation: 15 |\r\n| `noOfFacets` | No | number | `10` | How many facets must be added to the UI |\r\n| `dependsOn` | No | string | `` | Which other facet does this component rely on. Only when this facet has a selection the facets will be added. |\r\n| `debug` | No | boolean | `false` | Show the timing information for the facet requests. |\r\n| `useAdvancedQuery` | No | boolean | `false` | Must the advanced query (the facet selections) also be used to retrieve the facets. |\r\n| `useOnlyUserFields` | No | boolean | `true` | When retrieving facet fields from the index. Only use 'User' defined fields. Else 'System' fields will also be used. |\r\n| `usePush` | No | boolean | `false` | Use the Push approach (query the index on a specific push source). Make sure that the `queryToExecute` points to the push source. This will use the getValues of the defined facet (`pushGroupField`)|\r\n| `usePushAsQuery` | No | boolean | `false` | Use the Push approach (but examine the query instead of using the getValues method) |\r\n| `pushGroupField` | No | string |  | Field needed for the `usePush` method |\r\n| `tresholdPercentage` | No | number | `30` | A facet is only considered if it is present on `tresholdPercentage`% of the results |\r\n| `blacklist` | No | string | `field1,field2,field3` | The fields which should not be added to the UI |\r\n| `dictionary` | No | string | `` | See above for instructions |\r\n\r\n\r\n## Extending\r\n\r\nExtending the component can be done as follows:\r\n\r\n```javascript\r\nimport { DynamicQueryFacetGenerator, IDynamicQueryFacetGeneratorOptions } from \"@coveops/dynamic-query-facet-generator\";\r\n\r\nexport interface IExtendedDynamicQueryFacetGeneratorOptions extends IDynamicQueryFacetGeneratorOptions {}\r\n\r\nexport class ExtendedDynamicQueryFacetGenerator extends DynamicQueryFacetGenerator {}\r\n```\r\n\r\n## Contribute\r\n\r\n1. Clone the project\r\n2. Copy `.env.dist` to `.env` and update the COVEO_ORG_ID and COVEO_TOKEN fields in the `.env` file to use your Coveo credentials and SERVER_PORT to configure the port of the sandbox - it will use 8080 by default.\r\n3. Build the code base: `npm run build`\r\n4. Serve the sandbox for live development `npm run serve`\r\n","readmeFilename":"README.md"}