Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'upsert' does not exist on type 'AnalyticsRule'. #205

Open
naimulemon opened this issue May 9, 2024 · 1 comment
Open

Property 'upsert' does not exist on type 'AnalyticsRule'. #205

naimulemon opened this issue May 9, 2024 · 1 comment

Comments

@naimulemon
Copy link

Description

I want to create analytics collection for 'products' collect. On your documentation there are a upsert mathod but when I tried to implement this mathod it show me type error

Property 'upsert' does not exist on type 'AnalyticsRules | AnalyticsRule'.  

Here is my code example

  import { Injectable } from  '@nestjs/common';

import { Client } from  'typesense';

  

@Injectable()

export  class  TypesenseService {

private  client: Client;

  

constructor() {

this.client  =  new  Client({

nodes: [

{

host: process.env.TYPESENSE_HOST,

port: 443,

protocol: 'https',

},

],

apiKey: process.env.TYPESENSE_API_KEY,

});

}

  

async  createAnalyticsCollection() {

await  this.typeSenseClient()

.collections()

.create({

name: 'product_queries',

fields: [

{ name: 'q', type: 'string' },

{ name: 'count', type: 'int32' },

],

});

  

const  ruleName  =  'product_queries_aggregation';

const  ruleConfiguration  = {

type: 'popular_queries',

params: {

source: {

collections: ['products'],

},

destination: {

collection: 'product_queries',

},

limit: 1000,

},

};

  

await  this.client.analytics.rules().upsert(ruleName, ruleConfiguration);

}

  

typeSenseClient(): Client {

return  this.client;

}

}

Steps to reproduce

npm i typesense

Expected Behavior

I want to use upsert to create a analytics for collection

Actual Behavior

Metadata

Typesense Version: "typesense": "^1.8.2"

OS: Windows

@jasonbosco
Copy link
Member

Could you try replicating the issue using this example:

result = await typesense.analytics.rules().upsert("search_suggestions", {
type: "popular_queries",
params: {
source: { collections: ["products"] },
destination: { collection: "products_top_queries" },
limit: 10,
},
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants