Adding weather widget powerline - vim

I'm trying to enable weather widget for powerline but with no success. I added this code
{
"name": "weather",
"priority": 50,
"args": {
"unit": "F",
"location_query": "oslo, norway"
}
}
at the end of my theme file. When I start MacVim I get an error
Error detected while processing VimEnter Auto commands for "*":
2014-01-30 14:13:11,122:ERROR:vim:segment_generator:Failed to generate segment from {u'priority': 50, u'args': {u'location_query': u'oslo, norway', u'u
nit': u'F'}, u'name': u'weather'}: 'module' object has no attribute 'weather'
I've read powerline documentation but I'm still confused. Any help will be appreciated.

Here is how I configured weather for the Shell. I don't think it is possible with VI as it is not listed in the available segment
https://powerline.readthedocs.org/en/latest/configuration/segments/vim.html
Create the following folder tree:
~/.config/powerline/config.json
~/.config/powerline/themes/shell/netsamir.json
~/.config/powerline/colorschemes/shell/netsamir.json
~/.config/powerline/config.json
{
"common": {
"term_truecolor": false
},
"ext": {
"shell": {
"theme": "netsamir",
"colorscheme": "netsamir"
},
}
}
~/.config/powerline/themes/shell/netsamir.json
{
"segments": {
"above": [
{
"left": [
{
"function": "powerline.segments.common.wthr.weather",
"args": {
"unit": "C"
}
},
{
"name": "user",
"function": "powerline.segments.common.env.user",
"priority": 30
},
{
"function": "powerline.segments.common.vcs.branch",
"args": {
"status_colors": true,
"ignore_statuses": ["U"]
}
},
{
"name": "cwd",
"function": "powerline.segments.common.env.cwd"
}
]
}
],
"left": [
{
"type": "string",
"contents": ">",
"highlight_groups": ["promptline"],
"draw_soft_divider": false
},
{
"type": "string",
"contents": "",
"highlight_groups": ["blank"],
"draw_hard_divider": false
}
]
}
}
~/.config/powerline/colorschemes/shell/netsamir.json
{
"name": "netsamir",
"groups": {
"information:additional": { "fg": "gray9", "bg": "gray4", "attrs": [] },
"information:regular": { "fg": "gray10", "bg": "gray4", "attrs": [] },
"information:highlighted": { "fg": "white", "bg": "gray4", "attrs": ["bold"] },
"information:priority": { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] },
"hostname": { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
"background:divider": "information:additional",
"weather": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"user": { "fg": "brightcyan", "bg": "darkestblue", "attrs": ["bold"] },
"branch": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"branch_dirty": { "fg": "black", "bg": "orangered", "attrs": [] },
"branch_clean": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"branch:divider": { "fg": "gray7", "bg": "gray2", "attrs": [] },
"cwd": "information:additional",
"cwd:current_folder": "information:highlighted",
"cwd:divider": { "fg": "gray7", "bg": "gray4", "attrs": [] },
"promptline": { "fg": "white", "bg": "darkestblue", "attrs": ["bold"] },
"blank": { "fg": "black", "bg": "black", "attrs": [] }
}
}

Related

Opensearch transform splitting array values to new events

I'm transforming index that contains following event.
But the values inside of array are splitting into the new events.
e.g:
"serviceIdentifiers": "Redis"
"serviceIdentifiers":"Event_Detector Servicc"
etc.
{
"_index": "collated_txn_health_2022.05",
"_type": "_doc",
"_id": "LAUpboIBh6CUatILrsN3",
"_score": 1,
"_source": {
"timeInGMT": 0,
"kpiId": 0,
"compInstanceIdentifier": "d0352b7d-0484-4714-bbc8-eb67cbb7be70",
"agentIdentifier": "ComponentAgent-171",
"kpiIdentifier": "PACKETS_DROPPED",
"categoryIdentifier": "Network Utilization",
"applicationIdentifier": null,
"serviceIdentifiers": [
"Supervisor_Controller Service",
"Event_Detector Service",
"UI_Service",
"Redis",
"CC_Service"
],
"clusterIdentifiers": [
"a5c57ef5-4018-41b8-b727-27c8f8376c0e"
],
"collectionInterval": 60,
"value": "0.0",
"kpiType": "Core",
"groupAttribute": "ALL",
"groupIdentifier": null,
"watcherValue": null,
"errorCode": null,
"clusterOperation": null,
"aggLevelInMins": 1,
"error": false,
"kpiGroup": false,
"discovery": false,
"maintenanceExcluded": false,
"#timestamp": "2022-05-01T01:32:00.000Z"
}
Following is the transform job configuration.
curl -u admin:admin -XPUT "http://XXX.XXX.XX.XXX9201/_plugins/_transform/my-array-job-2" -H 'Content-type: application/json' -d'
{
"transform": {
"schedule": {
"interval": {
"start_time": 1659705000000,
"period": 1,
"unit": "Minutes"
}
},
"metadata_id": null,
"updated_at": 1659456180000,
"enabled": true,
"enabled_at": 1659457620000,
"description": "",
"source_index": "collated_txn_health_2022.05",
"data_selection_query": {
"match_all": {
"boost": 1
}
},
"target_index": "transform_collated_txn_health_2022.05",
"page_size": 1000,
"groups": [
{
"date_histogram": {
"fixed_interval": "1m",
"source_field": "#timestamp",
"target_field": "#timestamp",
"timezone": "Asia/Calcutta"
}
},
{
"terms": {
"source_field": "clusterIdentifiers",
"target_field": "clusterIdentifiers"
}
},
{
"terms": {
"source_field": "serviceIdentifiers",
"target_field": "serviceIdentifiers"
}
},
{
"terms": {
"source_field": "compInstanceIdentifier",
"target_field": "compInstanceIdentifier"
}
},
{
"terms": {
"source_field": "agentIdentifier",
"target_field": "agentIdentifier"
}
}
],
"aggregations": {
"count_#timestamp": {
"value_count": {
"field": "#timestamp"
}
}
}
}
}'
Following are the events from the transform index.
{
"_index": "transform_heal_collated_txn_health_2022.05",
"_type": "_doc",
"_id": "ybK0McQ9NZrt9xdo9iWKbA",
"_score": 1,
"_source": {
"transform._id": "my-array-job-2",
"transform._doc_count": 2,
"#timestamp": 1651365120000,
"clusterIdentifiers": "a5c57ef5-4018-41b8-b727-27c8f8376c0e",
"serviceIdentifiers": "Redis",
"compInstanceIdentifier": "a5c57ef5-4018-41b8-b727-27c8f8376c0e",
"agentIdentifier": "ComponentAgent-170",
"count_#timestamp": 2
}
},
{
"_index": "transform_heal_collated_txn_health_2022.05",
"_type": "_doc",
"_id": "Wf-4KwnFaYuw9bL-V-9WEQ",
"_score": 1,
"_source": {
"transform._id": "my-array-job-2",
"transform._doc_count": 2,
"#timestamp": 1651365120000,
"clusterIdentifiers": "a5c57ef5-4018-41b8-b727-27c8f8376c0e",
"serviceIdentifiers": "Redis_Server Service",
"compInstanceIdentifier": "a5c57ef5-4018-41b8-b727-27c8f8376c0e",
"agentIdentifier": "ComponentAgent-170",
"count_#timestamp": 2
}
It would be a great help if somebody suggest me with solution for array fields.
Have solved the issue with following painless script. Which help to transform array fields in opensearch.
PUT _plugins/_transform/my-array-job-2
{
"transform": {
"schedule": {
"interval": {
"start_time": 1659705000000,
"period": 1,
"unit": "Minutes"
}
},
"metadata_id": null,
"updated_at": 1659456180000,
"enabled": true,
"enabled_at": 1659457620000,
"description": "",
"source_index": "heal_collated_txn_heal_health_2022.05_reindex",
"target_index": "transform_heal_collated_txn_heal_health_2022.05",
"page_size": 1000,
"groups": [
{
"date_histogram": {
"fixed_interval": "1m",
"source_field": "#timestamp",
"target_field": "#timestamp",
"timezone": "Asia/Calcutta"
}
},
{
"terms": {
"source_field": "kpiIdentifier",
"target_field": "kpiIdentifier"
}
},
{
"terms": {
"source_field": "clusterIdentifiers",
"target_field": "clusterIdentifiers"
}
}
],
"aggregations": {
"count_#timestamp": {
"value_count": {
"field": "#timestamp"
}
},
"count_agentIdentifier": {
"value_count": {
"field": "agentIdentifier"
}
},
"sum_value": {
"sum": {
"field": "value"
}
},
"max_value": {
"max": {
"field": "value"
}
},
"avg_value": {
"avg": {
"field": "value"
}
},
"count_value": {
"value_count": {
"field": "value"
}
},
"percentiles_value": {
"percentiles": {
"field": "value",
"percents": [
95
],
"keyed": true,
"tdigest": {
"compression": 100
}
}
},
"serviceIdentifiers": {
"scripted_metric": {
"init_script": "state.docs = []",
"map_script": """
Map span = [
'url':doc['serviceIdentifiers']
];
state.docs.add(span)
""",
"combine_script": "return state.docs;",
"reduce_script": """
def all_docs = [];
for (s in states) {
for (span in s) {
all_docs.add(span);
}
}
def size = all_docs.size();
def serviceIdentifiers_1 = all_docs[0]['url'];
def ret = new HashMap();
ret['serviceIdentifiers'] = serviceIdentifiers_1;
return ret;
"""
}
}
}
}
}

Facing an error while building a custom skil for amazon alexa

I am trying to a build a basic custom alexa skill. I have created an intent schema and am using AWS lambda function as the endpoint. ]
My Intent schema:
{
"interactionModel": {
"languageModel": {
"invocationName": "toit brewpub",
"modelConfiguration": {
"fallbackIntentSensitivity": {
"level": "LOW"
}
},
"intents": [
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
},
{
"name": "GetClosingTime",
"slots": [],
"samples": [
"what time do you close",
"when is the last order",
"till what time are you open",
"What time does the pub close"
]
},
{
"name": "GetPriceOfBeer",
"slots": [
{
"name": "beer",
"type": "BEERS"
}
],
"samples": [
"how much is {beer}",
"what is the price of {beer}"
]
}
],
"types": [
{
"name": "BEERS",
"values": [
{
"name": {
"value": "Toit Red"
}
},
{
"name": {
"value": "Tiot Weiss"
}
},
{
"name": {
"value": "Basmati Blonde"
}
},
{
"name": {
"value": "Tintin Toit"
}
},
{
"name": {
"value": "IPA"
}
},
{
"name": {
"value": "Dark Knight"
}
}
]
}
]
}
}
}
I am using Node.js v 10.x for my lamda function which has been built using Alexa-Skills-NodeJS-Fact-kit, The region for my aws lambda is US_EAST- N.VIRGINIA.
Below is the request I receive when I talk to my Test Simulator:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.fd1c5315-ecf8-413f-ba25-e54bd6ae316a",
"application": {
"applicationId": "amzn1.ask.skill.72615503-5f38-4baf-b0dd-cd6edd3b6dfd"
},
"user": {
"userId": ""
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.72615503-5f38-4baf-b0dd-cd6edd3b6dfd"
},
"user": {
"userId": ""
},
"device": {
"deviceId": "",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": ""
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 160,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1024,
"pixelHeight": 600
}
}
}
}
]
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.24b64895-3f90-4a5b-9805-9d3b038cd323",
"timestamp": "2020-03-29T08:59:54Z",
"locale": "en-US",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
}
I have removed the user Id, device ID and access token while asking the question for security reasons.
My Lambda node js function looks like this which i have generated using the code generator :
https://github.com/shreyneil/Episodes/blob/master/amazon-echo/lambda-function.js
Url for code-generator: http://alexa.codegenerator.s3-website-us-east-1.amazonaws.com/
Url for tutorial that i was using to implement it: https://www.youtube.com/watch?v=BB3wwxgqPOU
Whenever i try to launch the event using , open toit brewpub in my test simulator it thorws an error stating :
There was a problem with the requested skill's response
Any idea on how to make this work?
Any leads would appreciated, Thank you!

Getting error "There was a problem with the requested skill's response" while developing Alexa Skill through Alexa Developers Console?

When testing out my skill using the Test Simulator for Alexa I am getting the following error:
"There was a problem with the requested skill's response"
I tried looking at solutions, but I could not find anything.
Below is my JSON Input 1 and I am not getting anything in JSON output.
Please help me here?
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.8df6ac89-2811-43cf-8578-e9edc30fa091",
"application": {
"applicationId": "amzn1.ask.skill.b1f0f00c-d3a9-43b9-82fe-92f066c58880"
},
"user": {
"userId": "amzn1.ask.account.AHNEWQLTUHO42PDYBLNORMFZURAPP5WSA52C6HPP4GEUM3MPBRYTY6WKULN3BNXIKPEOLUDQMX7EOLCG3E7LCD3YPJ4QL5JZ2N2UTX4UUFIWFY5PVGNSWC4JVO2EVFV5TDJD6HIPHU5O4KTSQW7XWBTUCSZ4JFPMFBPKEQ5IFLBZMXJI2XSRSMXKJV3PVJRSR5OT32LGO74AP2A"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.b1f0f00c-d3a9-43b9-82fe-92f066c58880"
},
"user": {
"userId": "amzn1.ask.account.AHNEWQLTUHO42PDYBLNORMFZURAPP5WSA52C6HPP4GEUM3MPBRYTY6WKULN3BNXIKPEOLUDQMX7EOLCG3E7LCD3YPJ4QL5JZ2N2UTX4UUFIWFY5PVGNSWC4JVO2EVFV5TDJD6HIPHU5O4KTSQW7XWBTUCSZ4JFPMFBPKEQ5IFLBZMXJI2XSRSMXKJV3PVJRSR5OT32LGO74AP2A"
},
"device": {
"deviceId": "amzn1.ask.device.AHUW3YVJLFTNIZQ7UUMLHULHQWHKPMW2UICHN4DZRBGBSYZJ3LMSUZLC4LP7Q5F4M7IXQOCAJ4KFNFB7GVAIRLIOHK7YN62XTX6LKRODFUKR2LP4RSGJUQCJGHXP7KIEFULCF6GVQD77DVPOC6OILLKGPEKADVW253ZEOJX4FGLG2SVWZMFHW",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLmIxZjBmMDBjLWQzYTktNDNiOS04MmZlLTkyZjA2NmM1ODg4MCIsImV4cCI6MTU4NTQ5NTU5NSwiaWF0IjoxNTg1NDk1Mjk1LCJuYmYiOjE1ODU0OTUyOTUsInByaXZhdGVDbGFpbXMiOnsiY29udGV4dCI6IkFBQUFBQUFBQVFDemhJWnNHUzR1L1cwK3VETTVuTkNjS2dFQUFBQUFBQUFZbjJTTllsbEhmUlVkbkFLU3E4Y0R3dXlNR2krUlUrWE90MVFuWXpkSERJUlpwUkhxdEoxcUZvMGRsM2YrRHFRSHJNeFFLaTlLR3FLa1RJQjlPOGJpUzcxZi9vMWJ6d1cvWlplcCtLTDlhem9yRUxYNjFXN2VBM3JnTy9PZkc0a1M4c1h5M2dmYTdEakxaUkRmUW9PWGZhZVJHa3p2Y1phUWQ4cmw4bDRWRlVsUnNLeEZadU9icmR3MTcvUkkxVHlWNERibFFhSHZjRXRtNUZJcnI4dmJ2bENyM3ZCWnJEVVFCSmxEN0ZrMG1lLzEwUHh2bnM1V05tcUl4ODN3WUFiUmdIUHEramhVZUpjM1lFcEpUYjcwZEllaHVoNUN4SDg3ZWZ5ckJPRDZFSnUwU1RCbmRQZGhnaXZnS3FNZUdVYkNWQmtzYmhVR1BIQy9HdjQxVmNlcDB2OXkrVk1iZFNROXFXbWV0aS9USm5hUFZWeVpyRFdLd0JDTGZ1RVoyWlloc2JzOGQxNTNPQlg2IiwiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUhVVzNZVkpMRlROSVpRN1VVTUxIVUxIUVdIS1BNVzJVSUNITjREWlJCR0JTWVpKM0xNU1VaTEM0TFA3UTVGNE03SVhRT0NBSjRLRk5GQjdHVkFJUkxJT0hLN1lONjJYVFg2TEtST0RGVUtSMkxQNFJTR0pVUUNKR0hYUDdLSUVGVUxDRjZHVlFENzdEVlBPQzZPSUxMS0dQRUtBRFZXMjUzWkVPSlg0RkdMRzJTVldaTUZIVyIsInVzZXJJZCI6ImFtem4xLmFzay5hY2NvdW50LkFITkVXUUxUVUhPNDJQRFlCTE5PUk1GWlVSQVBQNVdTQTUyQzZIUFA0R0VVTTNNUEJSWVRZNldLVUxOM0JOWElLUEVPTFVEUU1YN0VPTENHM0U3TENEM1lQSjRRTDVKWjJOMlVUWDRVVUZJV0ZZNVBWR05TV0M0SlZPMkVWRlY1VERKRDZISVBIVTVPNEtUU1FXN1hXQlRVQ1NaNEpGUE1GQlBLRVE1SUZMQlpNWEpJMlhTUlNNWEtKVjNQVkpSU1I1T1QzMkxHTzc0QVAyQSJ9fQ.L0hwnl1wAddgWkZBxbu9Q4nRHlzwWglcSiqzf4Z_Nzg8C4XzsP9-5x_wccMpDWRPQxE5s0YOf6UfkCooakR36lVkm6Z7PhVqJShNrF6YooC29vjJ50C1-_wg27AwcDWXBG4c_tjDTFcrAuwkNOo3pBUjA9xE00a3q6Ecs-UtD-stQXoLv4J0f8bpe7AEpfc1pzaqhBXkybYYA91IFLVX67Gvxqiag2CwjdT6BO0uayQqZpXZd5F4IRfYuLmsqK0aFIJv5g0h_kfwPusowLkGneegE2uTLE5SwZpZkWg9-aI-6HvdvRe1DvZbgnJKjw2SBRNGdKT-UOkJZTndI3mgag"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 160,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1024,
"pixelHeight": 600
}
}
}
}
]
},
"request": {
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.b0de7b26-cfba-4942-92b4-d5589c7b8db3",
"timestamp": "2020-03-29T15:21:35Z",
"locale": "en-IN",
"shouldLinkResultBeReturned": false
}
}

Phaser 3, loader plugin not load assets in pack.json file

I have a json file for load assets generated with phaser editor.
i have a file boot.js for load a image for make load bar, and preloasder.js for load other assets file.
in the browser console does not appears some kind of error, but the image isn't load.
boot.js
runner.Boot.prototype = {
preload: function() {
this.load.pack('boot', 'assets/pack.json'); //this not work
//this.load.image('logo','assets/img/logo.png');//this work
resize();
},
[...]
update: function(){
this.scene.start('Preloader');
}
in file preloader.js
this.preloadLogo = this.add.sprite(0, 0, 'logo');
but the key 'logo' is not load.
the file content in pack.json has not been loaded.
the content of pack.json
{
"boot": [{
"type": "image",
"key": "logo",
"url": "assets/img/logo.png",
"overwrite": false
}],
"preloader": [
{
"type": "spritesheet",
"key": "coin",
"url": "assets/img/coin.png",
"frameWidth": 20,
"frameHeight": 20,
"frameMax": -1,
"margin": 0,
"spacing": 0
},
{
"type": "spritesheet",
"key": "fire",
"url": "assets/img/fire.png",
"frameWidth": 40,
"frameHeight": 70,
"frameMax": -1,
"margin": 0,
"spacing": 0
},
{
"type": "spritesheet",
"key": "gattoboy",
"url": "assets/img/gattoboy.png",
"frameWidth": 64,
"frameHeight": 128,
"frameMax": -1,
"margin": 0,
"spacing": 0
},
{
"type": "spritesheet",
"key": "mountain",
"url": "assets/img/mountain.png",
"frameWidth": 512,
"frameHeight": 512,
"frameMax": -1,
"margin": 0,
"spacing": 0
},
{
"type": "image",
"key": "platform",
"url": "assets/img/platform.png",
"overwrite": false
},
{
"type": "image",
"key": "loader",
"url": "assets/img/loader.png",
"overwrite": false
},
{
"type": "image",
"key": "five",
"url": "assets/img/five.png",
"overwrite": false
},
{
"type": "image",
"key": "loader-frame",
"url": "assets/img/loader-frame.png",
"overwrite": false
},
{
"type": "image",
"key": "phaser",
"url": "assets/img/phaser.png",
"overwrite": false
}
],
"meta": {
"generated": "1576167834682",
"app": "Phaser Editor",
"url": "http://phasereditor.boniatillo.com",
"version": "1.0",
"copyright": "Arian Fornaris (c) 2015,2016"
}
}

ElasticSearch Highlighting fails on match queries against index with Ngram Analyzer

I have created an index with ngram analyzer set on all fields in the index and custom _all. After indexing few documents, I am trying to query against the index to have suggestion like feature.
The output of the query does return results but they are not highlighted.
Analyzer Settings:
"analysis": {
"analyzer": {
"my_edgegram_analyzer": {
"filter": [
"lowercase"
],
"tokenizer": "my_edge_tokenizer"
}
},
"tokenizer": {
"my_edge_tokenizer": {
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
],
"min_gram": "3",
"type": "ngram",
"max_gram": "26"
}
}
}
Mapping:
{
"st1": {
"mappings": {
"a": {
"_all": {
"enabled": false
},
"dynamic_templates": [
{
"catch_all": {
"match": "imp*",
"match_mapping_type": "string",
"mapping": {
"analyzer": "my_edgegram_analyzer",
"copy_to": "catch_all",
"norms": false,
"type": "text"
}
}
}
],
"properties": {
"catch_all": {
"type": "text",
"store": true,
"analyzer": "my_edgegram_analyzer"
},
"imp_server_id": {
"type": "text",
"norms": false,
"copy_to": [
"catch_all"
],
"analyzer": "my_edgegram_analyzer"
},
"imp_server_name": {
"type": "text",
"norms": false,
"copy_to": [
"catch_all"
],
"analyzer": "my_edgegram_analyzer"
}
}
},
"b": {
"_all": {
"enabled": false
},
"dynamic_templates": [
{
"catch_all": {
"match": "imp*",
"match_mapping_type": "string",
"mapping": {
"analyzer": "my_edgegram_analyzer",
"copy_to": "catch_all",
"norms": false,
"type": "text"
}
}
}
],
"properties": {
"catch_all": {
"type": "text",
"store": true,
"analyzer": "my_edgegram_analyzer"
},
"imp_server_id": {
"type": "text",
"norms": false,
"copy_to": [
"catch_all"
],
"analyzer": "my_edgegram_analyzer"
},
"imp_server_name": {
"type": "text",
"norms": false,
"copy_to": [
"catch_all"
],
"analyzer": "my_edgegram_analyzer"
}
}
}
}
}
}
Documents:
http://localhost:9200/st1/b/1
{"imp_server_name":"abc1-4-jam9.my.test.com","imp_server_id":"vrock2-us"}
http://localhost:9200/st1/a/1
{"imp_server_name":"abc2-5-ajm9.my.test.com","imp_server_id":"vrock2-us"}
Query:
{
"query": {
"match": {
"catch_all": {
"query":"test",
"analyzer": "keyword"
}
}
},
"highlight": {
"pre_tags": ["<b>"],
"post_tags": ["</b>"],
"fields": {
"*": {}
},
"require_field_match": false
}
}
Response:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.16292635,
"hits": [
{
"_index": "st1",
"_type": "a",
"_id": "1",
"_score": 0.16292635,
"_source": {
"imp_server_name": "abc2-5-ajm9.my.test.com",
"imp_server_id": "vrock2-us"
},
"highlight": {
"imp_server_name": [
"abc2-5-ajm9.my.test.com"
],
"catch_all": [
"abc2-5-ajm9.my.test.com"
]
}
},
{
"_index": "st1",
"_type": "b",
"_id": "1",
"_score": 0.16292635,
"_source": {
"imp_server_name": "abc1-4-jam9.my.test.com",
"imp_server_id": "vrock2-us"
},
"highlight": {
"imp_server_name": [
"abc1-4-jam9.my.test.com"
],
"catch_all": [
"abc1-4-jam9.my.test.com"
]
}
}
]
}
}
How can I make highlight work in the above scenario. Below is the expected output:
Expected output:
"highlight": {
"imp_server_name": [
"abc2-5-ajm9.my.<b>test</b>.com"
],
"catch_all": [
"abc2-5-ajm9.my.<b>test</b>.com"
]
}
I was able to get the results by setting term_vector in the schema.
"term_vector": "with_positions_offsets"

Resources