Giter VIP home page Giter VIP logo

Comments (4)

joemcelroy avatar joemcelroy commented on June 4, 2024

from searchkit.

Mehak-Singla avatar Mehak-Singla commented on June 4, 2024

index is in the previous version which was implemented
current code is this which is not working
async searchSchemesData(q: any, lang: string, sort: string, keyword: string, from: any, size: any) {

try{
const client = Client({
  connection: {
    host: process.env.OPENSEARCH_NODE_V3 + '/' + process.env.ELASTICSEARCH_INDEX_V3, // elasticsearch instance url
    headers: { 
      'Authorization': process.env.OPENSEARCH_KEY_V3 ? process.env.OPENSEARCH_KEY_V3 : ''
    }
  },
  search_settings: {
    highlight_attributes: ['schemeName','tags','briefDescription'],
    search_attributes: ['schemeName', 'briefDescription', 'tags'],
    result_attributes: ['schemeName', 'nodalMinistryName', 'briefDescription', 'schemeShortTitle', 'schemeCategory', 'schemeCloseDate', 'tags', 'slug', 'beneficiaryState'],
    facet_attributes: [
      { attribute: 'beneficiaryState.raw', field: 'beneficiaryState', type: 'string' }
    ]
  },
});

const results = await client.handleRequest([{"identifier":"benificiaryState","value":"Punjab"}], {
  hooks: {
    afterSearch: async (searchRequests, searchResponses) => {
      console.log(searchResponses);
      return Promise.resolve(searchResponses);
    },
  },
});
console.log(">>>>", results)
} catch(err) {
  console.log(">>>",err)
}

}

from searchkit.

Mehak-Singla avatar Mehak-Singla commented on June 4, 2024

Performing search with requests:
POST /_msearch
{}
{"query":{"bool":{"filter":[],"must":{"match_all":{}}}},"size":20,"from":0,"_source":{"includes":["schemeName","nodalMinistryName","briefDescription","schemeShortTitle","schemeCategory","schemeCloseDate","tags","slug","beneficiaryState"]},"highlight":{"pre_tags":[""],"post_tags":[""],"fields":{"schemeName":{"number_of_fragments":0},"tags":{"number_of_fragments":0},"briefDescription":{"number_of_fragments":0}}}}

Elasticsearch response:
{"took":3,"responses":[{"took":3,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":536,"relation":"eq"},"max_score":1,"hits":[{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"W2-SnIkBY4joYqdttLNa","_score":1,"_source":{"beneficiaryState":["Arunachal Pradesh"],"schemeShortTitle":"DK","nodalMinistryName":null,"schemeCategory":["Social welfare & Empowerment"],"schemeName":"Dulari Kanya","schemeCloseDate":null,"slug":"dk","briefDescription":"“Dulari Kanya” is a scheme for the girl child by the Govt. of Arunachal Pradesh. The objective of the scheme is to end the preference between male and female child, encouragement of institutional delivery, immunization of children, to end child marriage and overall empowerment of females.","tags":["Girl Child","Social Welfare","Financial Assistance"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"cW-SnIkBY4joYqdttLNg","_score":1,"_source":{"beneficiaryState":["Jammu and Kashmir"],"schemeShortTitle":"ISSS-PPCP","nodalMinistryName":null,"schemeCategory":["Social welfare & Empowerment"],"schemeName":"Integrated Social Security Scheme - Pension For Physically Challenged Persons","schemeCloseDate":null,"slug":"isss-ppcp","briefDescription":"ISSS-PPCP is a State Sponsored Scheme by the Social Welfare Dept. of the Govt. of J&K wherein financial assistance is provided to Physically Challenged Person who have meager support or no source of livelihood. A pension of ₹1000 per pensioner per month is deposited into their bank account.","tags":["Pension","PwD","Disability","Social Welfare"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"bG-SnIkBY4joYqdttLNg","_score":1,"_source":{"beneficiaryState":["Uttar Pradesh"],"schemeShortTitle":"BBY","nodalMinistryName":null,"schemeCategory":["Social welfare & Empowerment"],"schemeName":"Berojgari Bhatta Yojna","schemeCloseDate":null,"slug":"bby","briefDescription":"The UP government has implemented the UP Unemployment Allowance 2022 scheme in Uttar Pradesh. The government has implemented this scheme only for those candidates who belong to the state and is unemployed despite being educated.","tags":["Berojgari Bhatta","Financial Assistance","Rojgaar Samgam",null]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"cm-SnIkBY4joYqdttLNh","_score":1,"_source":{"beneficiaryState":["Rajasthan"],"schemeShortTitle":"RCMRF-KP","nodalMinistryName":null,"schemeCategory":["Social welfare & Empowerment"],"schemeName":"Rajasthan Chief Minister's Relief Fund - Kargil Package","schemeCloseDate":null,"slug":"rcmrf-kp","briefDescription":"Rajasthan Chief Minister’s Relief Fund – Kargil package scheme launched on April 1999 under Chief Minister’s Relief Fund in Rajasthan for the Individual and family.","tags":[]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"dG-SnIkBY4joYqdttLNi","_score":1,"_source":{"beneficiaryState":["Delhi"],"schemeShortTitle":"SMSSS","nodalMinistryName":null,"schemeCategory":["Education & Learning"],"schemeName":"Scholarship/merit Scholarship To Sc/st Students From Class I To Xii","schemeCloseDate":null,"slug":"smsss","briefDescription":"The Department for the Welfare of SC/ST/OBC is implementing 9 types of Scholarship Schemes for the SC/ST/OBC/Min, including CSS schemes & five State- Funded Schemes, online, on e-district Portal. Scholarship/Merit Scholarship to SC/ST/OBC/Minorities students (Class I TO XII) scheme is one of these.","tags":["Scholarship","Merit Scholarship","Students","Direct Benefit Transfer","Class I To XII"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"eW-SnIkBY4joYqdttLNj","_score":1,"_source":{"beneficiaryState":["Odisha"],"schemeShortTitle":"E-M","nodalMinistryName":null,"schemeCategory":["Education & Learning"],"schemeName":"E-Medhabruti","schemeCloseDate":null,"slug":"e-m","briefDescription":"The scheme "e-Medhabruti" is a Scholarship Scheme by the Higher Education Department, Government of Odisha. The objective of the scheme is to provide financial assistance of up to ₹ 20,000 to meritorious students of Odisha whose parental income does not exceed ₹ 6,00,000.","tags":["Scholarship","Undergraduate","Postgraduate"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"im-SnIkBY4joYqdttbMc","_score":1,"_source":{"beneficiaryState":["All"],"schemeShortTitle":"AFFDF","nodalMinistryName":"Ministry Of Defence","schemeCategory":["Health & Wellness"],"schemeName":"AFFDF-Financial Assistance For Procuring Mobility Equipment To Disabled Ex-Servicemen(All Ranks)","schemeCloseDate":null,"slug":"affdf","briefDescription":"A scheme to provide financial assistance for procurement of modified scooter for those Ex-Servicemen, who are disabled after their retirement from service with disability of 50% or more.","tags":["Ex-Servicemen","Differently Abled"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"jG-SnIkBY4joYqdttbMf","_score":1,"_source":{"beneficiaryState":["All"],"schemeShortTitle":"SR","nodalMinistryName":"Ministry Of Agriculture and Farmers Welfare","schemeCategory":["Education & Learning","Agriculture,Rural & Environment"],"schemeName":"Students Ready","schemeCloseDate":null,"slug":"sr","briefDescription":"The Student Rural Entrepreneurship Awareness Development Yojana (READY) was launched by Hon'ble Prime Minister on 25 July 2015.\n","tags":["Student","Ready","Agriculture"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"j2-SnIkBY4joYqdttbMf","_score":1,"_source":{"beneficiaryState":["Arunachal Pradesh"],"schemeShortTitle":"CMAAY","nodalMinistryName":null,"schemeCategory":["Health & Wellness"],"schemeName":"Chief Minister Arogya Arunachal Yojana(cmaay)","schemeCloseDate":null,"slug":"cmaay","briefDescription":" Under this scheme coverage of upto 5 lakh per family per year is made available by the State Government. In addition to that Pre-hospitalization expenses for up to 3 days and post-hospitalization expenses for up to 10 days are covered.","tags":[]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"mm-SnIkBY4joYqdttbMj","_score":1,"_source":{"beneficiaryState":["Uttarakhand"],"schemeShortTitle":"MUKUY","nodalMinistryName":null,"schemeCategory":["Sports & Culture"],"schemeName":"Mukhyamantri Udiyaman Khiladi Unnayan Yojana","schemeCloseDate":null,"slug":"mukuy","briefDescription":"Uttarakhand Chief Minister Pushkar Singh Dhami ji started the Mukhyamantri Udeeyman Khiladi Unnayan Yojana 2022 by participating in the program organized on the occasion of National Sports Day.","tags":["Udiyaman","Khiladi Unnayan","Sports","Uttarakhand"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"tW-SnIkBY4joYqdttbO8","_score":1,"_source":{"beneficiaryState":["All"],"schemeShortTitle":"SBM - G II","nodalMinistryName":"Ministry Of Jal Shakti","schemeCategory":["Utility & Sanitation","Health & Wellness"],"schemeName":"Swachh Bharat Yojana – Grameen Phase II","schemeCloseDate":null,"slug":"sbm-g-ii","briefDescription":"A sanitation scheme for Visual cleanliness through Open Defecation Free (ODF) sustainability and effective management of solid and liquid waste in villages","tags":["Swachh Bharat","Toilet","Sanitation","Rural","Grameen"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"w2-SnIkBY4joYqdttbPA","_score":1,"_source":{"beneficiaryState":["All"],"schemeShortTitle":"MCM-MIN","nodalMinistryName":"Ministry Of Minority Affairs","schemeCategory":["Education & Learning","Social welfare & Empowerment"],"schemeName":"Merit Cum Means Based Scholarship For Students Belonging To The Minority Communities","schemeCloseDate":null,"slug":"mcm-min","briefDescription":"A scholarship scheme by the Ministry of Minority Affairs for students from minority communities pursuing technical and professional courses at undergraduate and postgraduate levels in a listed institute. A total of 60,000 scholarships are targeted to be distributed as ‘Fresh’ Scholarships.","tags":["Student","Scholarship","Minority","Higher Education"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"xG-SnIkBY4joYqdttbPA","_score":1,"_source":{"beneficiaryState":[],"schemeShortTitle":"PRE-SC","nodalMinistryName":"Ministry Of Social Justice and Empowerment","schemeCategory":["Education & Learning","Social welfare & Empowerment"],"schemeName":"Centrally-Sponsored Scheme Of Pre-Matric Scholarship For Scheduled Caste Students Studying In Classes 9th & 10th","schemeCloseDate":null,"slug":"pre-sc","briefDescription":"A scholarship scheme by Ministry of Social Justice & Empowerment for regular, full-time students from Scheduled Castes studying in Class 9th and 10th in a Govt. School / a School recognized by Govt. / CBSE / State Board of Secondary Education.","tags":["Pre Matric","Scholarship","Scheduled Caste","Student","Social Welfare","Person With Disability"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"y2-SnIkBY4joYqdttbPD","_score":1,"_source":{"beneficiaryState":["Karnataka"],"schemeShortTitle":"SLG","nodalMinistryName":null,"schemeCategory":["Education & Learning"],"schemeName":"Stipend To Law Graduates","schemeCloseDate":null,"slug":"slg","briefDescription":"Under this scheme, the Social Welfare Department, Govt of Karnataka will give a stipend to the Law Graduates belonging to SC/ST Community residing in Karnataka. This will help them to practice law in various courts and training courses will also be organized under the guidance of senior advocates.","tags":["SC","ST","Stipend","Law Graduates","Karnataka"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"4G-SnIkBY4joYqdttbPl","_score":1,"_source":{"beneficiaryState":["Maharashtra"],"schemeShortTitle":"GSGOS","nodalMinistryName":null,"schemeCategory":["Business & Entrepreneurship","Skills & Employment"],"schemeName":"Group Supply Of Goats And Sheep","schemeCloseDate":null,"slug":"gsgos","briefDescription":"Group supply of goats and sheep refers to the practice of selling or distributing goats and sheep in groups, rather than as individual animals. In Maharashtra, this practice is common among farmers, livestock traders, and cooperative organizations. ","tags":["Tribal Scheme","Goat Supply","Sheep Supply","Maharashtra Scheme","State Scheme"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"7m-SnIkBY4joYqdttbPs","_score":1,"_source":{"beneficiaryState":["Telangana"],"schemeShortTitle":"KCR NUTRITION KIT","nodalMinistryName":null,"schemeCategory":["Health & Wellness","Social welfare & Empowerment"],"schemeName":"KCR Nutrition Kit","schemeCloseDate":null,"slug":"kcr-nutrition-kit","briefDescription":"KCR Nutrition Kits Scheme is a welfare initiative launched by the Government of Telangana, India, aimed at providing nutritious food to pregnant. The primary objective of the scheme is to improve the nutritional status of pregnant women. ","tags":["Pregnant Women Care Kit","Providing Nutritious Food To Pregnant Women And Children","Anganwadi Centers","Improve The Nutritional Status Of Pregnant"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"72-SnIkBY4joYqdttbPs","_score":1,"_source":{"beneficiaryState":["Assam"],"schemeShortTitle":"ADOW","nodalMinistryName":null,"schemeCategory":["Business & Entrepreneurship"],"schemeName":"Aamar Dukan On Wheels","schemeCloseDate":null,"slug":"adow","briefDescription":"The Assam Government proposes to introduce a new module of “Aamar Dukan” namely “AAMAR DUKAN ON WHEELS” in the same line as the existing ‘Aamar Dukan’ on 22.02.2017.","tags":["Aamar Dukan","Wheels","Business","Startup"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"8G-SnIkBY4joYqdttbPu","_score":1,"_source":{"beneficiaryState":["Mizoram"],"schemeShortTitle":"MRF","nodalMinistryName":null,"schemeCategory":["Education & Learning"],"schemeName":"Mizoram Research Fellowship","schemeCloseDate":null,"slug":"mrf","briefDescription":"The "Mizoram Research Fellowship" aims to provide financial assistance to research workers and teachers, preferably below the age of 45 years, who have established their reputation for research OR have obtained a doctorate degree OR have published research work to their credit.","tags":["Fellowship","PhD","Research","Postgraduation"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"8W-SnIkBY4joYqdttbPu","_score":1,"_source":{"beneficiaryState":["Jharkhand"],"schemeShortTitle":"NPY-JBOCWWB","nodalMinistryName":null,"schemeCategory":["Banking,Financial Services and Insurance","Social welfare & Empowerment"],"schemeName":"Nishaktata Pension Yojana (JBOCWWB)","schemeCloseDate":null,"slug":"npy-jbocwwb","briefDescription":""Nishaktata Pension Yojana (JBOCWWB)" is a scheme by the Department of Labour, Employment, Training & Skill Development Govt of Jharkhand. The scheme provides a pension of ₹ 1,000/- per month to the registered beneficiary who is permanently disabled due to paralysis/leprosy/tuberculosis/accident.","tags":["Pension","Disability","Construction Worker","Social Welfare"]}},{"_index":"dev_my_scheme_v3","_type":"_doc","_id":"Ym-SnIkBY4joYqdttLNb","_score":1,"_source":{"beneficiaryState":["Assam"],"schemeShortTitle":"SS-A","nodalMinistryName":null,"schemeCategory":["Health & Wellness"],"schemeName":"Sneha Sparsha","schemeCloseDate":null,"slug":"ss-a","briefDescription":""Sneha Sparsha" is a healthcare scheme by the Dept. of Health & Family Welfare, Govt. of Assam. In this scheme, financial assistance shall be provided for specialized treatment of children below 12 years of age affected with some serious ailments.","tags":["Disease","Child","Financial Assistance"]}}]},"status":200}]}
[
{
took: 3,
timed_out: false,
_shards: { total: 1, successful: 1, skipped: 0, failed: 0 },
hits: { total: [Object], max_score: 1, hits: [Array] },
status: 200
}
]
Error: Error transforming Elasticsearch response for index
at transformResponse (/home/unthinkable/Work/NeGd/myscheme-search-service/node_modules/searchkit/src/transformResponse.ts:243:11)
at /home/unthinkable/Work/NeGd/myscheme-search-service/node_modules/searchkit/src/index.ts:82:16
at Array.map ()
at Searchkit.handleInstantSearchRequests (/home/unthinkable/Work/NeGd/myscheme-search-service/node_modules/searchkit/src/index.ts:77:50)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at SearchService.searchSchemesData (/home/unthinkable/Work/NeGd/myscheme-search-service/src/search-v3/search.service.ts:779:21)
at SearchSchemeController.searchSchemes (/home/unthinkable/Work/NeGd/myscheme-search-service/src/search-v3/search.controller.ts:103:20)

Error: Error transforming response. Check the afterSearch hook function is correct. Likely you are not returning the correct response object.
at Searchkit.handleInstantSearchRequests (/home/unthinkable/Work/NeGd/myscheme-search-service/node_modules/searchkit/src/index.ts:95:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at SearchService.searchSchemesData (/home/unthinkable/Work/NeGd/myscheme-search-service/src/search-v3/search.service.ts:779:21)
at SearchSchemeController.searchSchemes (/home/unthinkable/Work/NeGd/myscheme-search-service/src/search-v3/search.controller.ts:103:20)

Also in debug mode true it is bringing all results,

  1. though I am asking for one particular state {"identifier":"benificiaryState","value":"Punjab"},
  2. And if query is incorrect n bringing all result it should return but i am getting error.

from searchkit.

joemcelroy avatar joemcelroy commented on June 4, 2024

closing issue, resolved on discord.

from searchkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.