Which javascript/node module is best for Elastic search Query DSL - elasticsearch

Hi started using elasticsearch in my node app, from the elasticsearch document,
elastic.js, esq, or bodybuilder can be used to make building query
bodies easier.
I am not sure which is the best module to use, both modules have not been updated since a while.Bodybuilder does not support all the filters/queries, elastic.js looks like it supports most of the filters/queries, but its documentation is inaccessible. Can somebody suggest me a good module.

The official js library is the best, I would say.
For the query, I create my own, concatenating values.
This is the most complete example for using it: Link.
That and do previous to that one in the same page.

Related

Using Nlog logger with ECS layout, in kibana the json object appear as a string instead of multiple properties

I'm working on some .Net framework application and i've been asked to send the logs to elasticsearch using kibana as the UI.
To have something that is standardized i have to implement ECS (Elastic Common Schema).
Looking at the example we have on ECS github we only have to implement it on the following way:
Instead of sending to console, like we have on the example i send it to elastic search
The output from it, would be a nice Json object...
Maybe it is expected that on kibana we would see something like the following (Kibana - Discover):
Looking at that, probably the Json Object is supposed to be treated as a string and everything goes inside the message property, but that is not what i'm looking for, i want that json to be divided in many properties.
Since i'm new to Elastic stack world, i've tried to create a template inside the Index Management page and the performing there manual mappings like message._metadata.url to not treat some properties as part of the string but without success.
I'm having trouble finding useful information to solve this problem, can anyone give an hint?
UPDATE:
I found the property enableJsonLayout="true"that we can put on the target of Nlog that indeed turns whats on the Json layout as properties on ElasticSearch which is good.
Is this the right way to use ECS?
How can i add aditional properties?
When you enable this enableJsonLayout="true" then it means that the configured Layout has to handle everything. For EcsLayout then you can find the documentation here:
https://github.com/elastic/ecs-dotnet/tree/master/src/Elastic.CommonSchema.NLog
EcsLayout will by default include all LogEvent Properties as metadata. See also https://github.com/NLog/NLog/wiki/How-to-use-structured-logging
But you can explicit add extra metadata-items:
<layout xsi:type="EcsLayout">
<metadata name="MyProperty" layout="MyPropertyValue" />
</layout>

How to override entity pluralisation?

I've started playing around with API Platform and it's looking like a fantastic but of kit and generally a quick Google or Stack Overflow search answers and questions I might have.
However, this one I'm struggling with and it could be a simple terminology issue...
How do I go about changing or overriding the automatic pluralisation of entity names? I.e. Fleet is becoming Fleets.
Any tips on where to look for documentation or any quick examples of how to do what I'm after? I'm using annotations.
Thanks in advance!
You can create custom Operation Path Resolver which doesn't use Inflector::pluralize().
There is section in docs about it (https://api-platform.com/docs/core/operation-path-naming/#create-a-custom-operation-path-resolver).
It requires creating custom class which implements OperationPathResolverInterface (https://github.com/api-platform/core/blob/master/src/PathResolver/OperationPathResolverInterface.php)

Wagtail alongside Django Rest Framework drf-yasg?

I am implementing a Wagtail powered blog within a larger (primarily DRF) driven app. I'm attempting to use drf-yasg for my documentation.
Since installing wagtail, the docs are now throwing
'Request' object has no attribute 'wagtailapi_router'
It looks to be related to the introspection that drf-yasg does, and all I can find about excluding views from drf-yasg is done at the code level. Being an installed module obviously I want to avoid that.
Has anyone got these 2 (3) components playing nicely together?
It's been a very long time since you asked this question, but as I found this while looking for an answer myself, I thought I might share what worked for me.
Note that I'm not using drf-yasg, but rather DRF's own schema generator. They do however have a lot in common.
The problem in my case was that the schema generator URL was defined like this:
path(
"schema/",
get_schema_view(title="My API Schema"),
name="openapi-schema",
),
What I needed to add was a patterns= argument that referenced my API specifically, leaving out the other non-API urls (like Wagtail):
path(
"v3/schema/",
get_schema_view(title="My API Schema", patterns=router.urls),
name="openapi-schema",
),
I hope that helps... someone :-D

Google Analytics Reporting API filters/segements

I'm trying to use the Google Analytics Core Reporting API and have the following troubles. I know how to fetch that I want the problem I have is:
I want to use a filter only for specific metrics and not for all of them.
Is this even possible?
Here is an example how my Reporting "Code" looks like:
Metrics "ga:sessions
ga:goal6Completions
ga:goal7Completions
ga:goal10Completions
ga:totalEvents
ga:uniqueEvents"
Dimensions "ga:date"
Filters "ga:eventCategory==customerType"
I have the same problems with segments as with the filters that all metrics all segmented/filtered and only specific metrics should.
There really isn't another way other to get the data you want without creating a new request where the filter isn't applied unfortunately.
Just remember that you are only allowed five requests total. To give context, this may only apply to how I use the Reporting API, but I use Google App Script to push data to Google Sheets.
This may or may not be helpful to you, but the reporting code I use I have made available in a repo on GitHub: https://github.com/jessfeliciano/aggregateGoogleAnalyticsReporting/blob/master/objectQueryWithFilter.js
I've included a guide that gives additional information regarding creating requests in general, so it may spark other ways to go about creating your data trees. I hope this helps.

How can I index sub-community discussions and events?

I have written a custom crawler to index all the data from the connections seedlists
https:///forums/seedlist/myserver
When we started utilizing subcommunities, I double checked to make sure subcommunities behave practically the same as communities. They seem to, they have all the same properties in the Connections DB, just subs have a parent uuid. Got it.
I expected my crawler to find the sub communities discussions (basically just iterating through the atom feed with a Java XML parser) and pulling out the relevant information. Are subcommunities not published to this seedlist? If not, there does not seem to be a subcommunity specific seedlist.
We are currently on Connections 4.5
Thank you.
I have found the answer here.
http://www-10.lotus.com/ldd/appdevwiki.nsf/xpDocViewer.xsp?lookupName=IBM+Connections+4.5+API+Documentation#action=openDocument&res_title=Community_entry_content_ic45&content=pdcontent
There seems to be an additional element that links to the sub-community feed from within the community. A crawler will need to send a GET request to that link.

Resources