JavaScript Archives - Capture Club

List All Loaded Classes in the Java JVM Using Nashorn JavaScript

  As I was working through an issue the other day, at one point I wanted to see what was loaded in the Java Virtual Machine (JVM).  To make matters a bit more tricky, I had to accomplish this using Nashorn JavaScript.  So after a bit of poking around, I found this in Java: import […]

kmcowan 17 August, 2018 0

TAME: Truly Asynchronous Messaging Environment

When we talk about asynchronous communication on the internet, we’re not really talking about pure asynchronicity.   When a JavaScript client makes a standard AJAX request, it is waiting for a response — a single response — and that completes that particular communication event.  The reason this is called “asynchronous” is because it happens after the […]

kmcowan 26 July, 2018 0

Making Asynchronous Requests — Lucidworks Fusion JavaScript Stage

There are many ways you can make an asynchronous request in a JavaScript stage. Using the Apache HTTP Client Using the native Java URL or URI classes Using the native Java HttpConnection class Using the Jsoup built-in connect() method Examples of each 1) Apache HTTP Client function(doc) { var BufferedReader = java.io.BufferedReader; var InputStreamReader = […]

kmcowan 7 May, 2018 0

"Stateful" persistence in a Fusion JavaScript Pipeline

One of the most useful features of Nashorn JavaScript in Lucidworks Fusion is the ability to access Java objects within the context of your JavaScript stage. Often times, you’ll want to maintain the state of a variable; or maybe you want to only make a REST call once, and store the result. You can certainly […]

kmcowan 5 May, 2018 0

Making an Authenticated REST Call in a Fusion Pipeline

REST… easy! There are times you just need to reach outside the box and do something. Sometimes that something would be launching a process, or perhaps making an alternate query, or even calling some third party API, like ESRI. If the REST call you’re making doesn’t require authentication, you can do that with a plain, […]

kmcowan 4 May, 2018 0

Multi-threaded JavaScripting Using the Nashorn JavaScript Engine

I have been writing JavaScript for enterprise applications for more than 20 years. From that statement, it’s easy to discern that I’ve been a JavaScript advocate for a long, long time. JavaScript is a truly unique language, sporting qualities found in both procedural and functional languages. Despite this, there has always been one glaring missing […]

kmcowan 3 May, 2018 0

Extracting Values from Element Attributes using Jsoup and a JavaScript Stage

While Fusion comes with built-in Jsoup selector functionality, it is limited in its extraction capability. If you want to do something like extract attribute values — in particular attribute values with special characters or empty spaces in the values, you’ll need to do a custom JavaScript stage and implement the extraction there. To accomplish this: […]

Overriding the Query Pipeline, Pt III

When we last left our rogue query pipeline in Pt II, we had made our Solr query and had tucked the response into a JSON object.  This call was made from our “main” function, which is incidentally the last function — an anonymous function — declared at the end of your stage.  For example: function […]

Overriding the Query Pipeline in Lucidworks Fusion 3.x

One of the most common questions I come across when discussing a query pipeline solution would have to be this: “How do I alter or transform the final result set?” The short answer, in Fusion 3, is that you’re not able to modify that in a query pipeline, but that you would need a middle […]

kmcowan 2 May, 2018 1