Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/synapticloop/panl
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/synapticloop/panl/server/handler/CollectionRequestHandler.java
  • Loading branch information
synapticloop committed Sep 18, 2024
2 parents a5087dd + 246d6ae commit 23f5815
Show file tree
Hide file tree
Showing 22 changed files with 214 additions and 48 deletions.
45 changes: 45 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This config was automatically generated from your source code
# Stacks detected: cicd:jenkins:.,deps:java:.,tool:gradle:
version: 2.1
jobs:
test-java:
docker:
- image: cimg/openjdk:17.0
steps:
- checkout
- run:
name: Calculate cache key
command: |-
find . -name 'pom.xml' -o -name 'gradlew*' -o -name '*.gradle*' | \
sort | xargs cat > /tmp/CIRCLECI_CACHE_KEY
- restore_cache:
key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }}
- run:
command: ./gradlew check
- store_test_results:
path: build/test-results
- save_cache:
key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }}
paths:
- ~/.gradle/caches
- store_artifacts:
path: build/reports
deploy:
# This is an example deploy job, not actually used by the workflow
docker:
- image: cimg/base:stable
steps:
# Replace this with steps to deploy to users
- run:
name: deploy
command: '#e.g. ./deploy.sh'
- run:
name: found jenkins config
command: ':'
workflows:
build-and-test:
jobs:
- test-java
# - deploy:
# requires:
# - test-java
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@

---

**_Get up and running with a fully featured, SEO friendly, keyword searchable, faceted search engine with an in-built, example search page to test it all out._**
> **_Get up and running with a fully featured, SEO friendly, keyword searchable, faceted search engine with an in-built, example search page to test it all out._**
---

```
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# __ #
# .-----.---.-.-----.| | #
# | _ | _ | || | #
# | __|___._|__|__||__| #
# |__| ... .-.. #
# #
# ~ ~ ~ * ~ ~ ~ #
# #
# #
# SOLR/PANL #
# #
# ---------- #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
```

`Build and test 'main' branch:` [![CircleCI](https://dl.circleci.com/status-badge/img/circleci/3Y1eqqe4mcvtSZuzJnQ3tJ/DyFKUm7c7AoLa1wHmRjAnf/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/circleci/3Y1eqqe4mcvtSZuzJnQ3tJ/DyFKUm7c7AoLa1wHmRjAnf/tree/main)

`Latest release tag:` ![GitHub Tag](https://img.shields.io/github/v/tag/synapticloop/panl)

`Latest release:` ![GitHub Release](https://img.shields.io/github/v/release/synapticloop/panl)

## Download the Panl Server Release:

[https://github.com/synapticloop/panl/releases](https://github.com/synapticloop/panl/releases)
Expand All @@ -17,7 +41,7 @@
- Online book (HTML): [https://synapticloop.github.io/panl/](https://synapticloop.github.io/panl/)
- Offline book (PDF): [Getting Started With Synapticloop Panl.pdf](https://github.com/synapticloop/panl/blob/main/src/dist/book/Getting%20Started%20With%20Synapticloop%20Panl.pdf)

Both of the book links above refer to Solr Panl integration 9 with help for earlier versions of Solr.
Both of the book links above refer to Solr Panl integration 9 with instructions for setting up and running earlier versions of Solr.

## Why?

Expand Down Expand Up @@ -100,7 +124,7 @@ _The image is a screenshot of the in-built Panl Results Viewer Web App available

## The Panl Results Explainer Web App

<img src="src/docs/panl-results-explainer.png" alt="The In-Built Panl Results Explainer" /">
<img src="src/docs/panl-results-explainer.png" alt="The In-Built Panl Results Explainer" />

_**Image**: The features and functionality of the Panl results explainer_

Expand Down Expand Up @@ -356,10 +380,12 @@ with the release files named `solr-panl-9-x.x.x`
- Update Mechanical Pencils
- Added in hierarchy for the Pencil Model example
- Dynamic range functionality - pulling actual values for the facet
- Suppress facet values for ranges, so that the user may only select from the range UI, and the individual range facet values do not appear


- Documentation update
- New documentation for additional features and functionality
- Fixed general spelling and grammar errors
- Added in documentation for new features and functionality
- Updated mechanical pencils introductory dataset explanations
- Added in documentation for Fields

Expand Down
10 changes: 5 additions & 5 deletions src/dist/sample/data/mechanical-pencils.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"variants": [ "Light Blue" ],
"colours": [ "Blue" ],
"id": 7,
"description": "",
"description": "Whilst the design has probably not been updated in 50 years, it has an appealing classic retro look about it. I can understand wanting to keep the classic design of the clip and clip mechanism, however, times have changed and technology is better, and the clip needs to be better. This pencil looks like it is a no-nonsense, workhorse of a pencil that gets out of the way to let you do your work. At home on a drafting board for technical drawings, or just to pull out for jotting notes or doing a quick sketch.",
"images": [
"400-alvin-tech-da-blue-body-with-red-cap.jpg",
"400-alvin-tech-da-blue-body-with-green-cap.jpg",
Expand Down Expand Up @@ -179,7 +179,7 @@
"variants": [ "Silver", "Black", "White" ],
"colours": [ "Silver", "Black", "White" ],
"id": 8,
"description": "",
"description": "This pencil is an ‘update’ to the original, full-metal, classic Bic Criterium 2603 model, it had the same hexagonal shape and size, but the body was aluminium not plastic. The grip was also subtly different from the current design. It is a shame that they ‘updated’ the body to be plastic. The original Criterium pencil with grip styling — was manufactured by Conté. Generally, Bic products are well made, if you get one with a proper mechanism, or invest a small amount of time in fixing one that isn’t working, then this is a great entry-level pencil.",
"images": [
"400-bic-criterium-silver.jpg",
"400-bic-criterium-white.jpg",
Expand Down Expand Up @@ -217,7 +217,7 @@
"variants": [ "Black with red cap", "Black with blue cap", "Black with black cap" ],
"colours": [ "Black" ],
"id": 9,
"description": "",
"description": "This is the pencil for people who know about pencils. Understated and those who know will appreciate the craftsmanship that went into this and will be duly impressed. Not as common as the Rotring or Staedtler, but far more impressive to own.\n\nIf you like something light and want to make a very understated statement, this is the pencil for you.\n\nIf you like these pencils, the choice comes down to textured vs non-textured grip and the colour of the cap.\n\nThis is a pencil to own if you want to pay homage to the creator of the mechanical pencil.",
"images": [
"400-caran-d-ache-fixpencil-22--smooth--black-body-with-red-cap.jpg",
"400-caran-d-ache-fixpencil-22--smooth--black-body-with-blue-cap.jpg",
Expand Down Expand Up @@ -255,7 +255,7 @@
"variants": [ "Black with red cap", "Black with blue cap", "Black with black cap" ],
"colours": [ "Black" ],
"id": 10,
"description": "",
"description": "This is the pencil for people who know about pencils. Understated and those who know will appreciate the craftsmanship that went into this and will be duly impressed. Not as common as the Rotring or Staedtler, but far more impressive to own.\n\nIf you like something light and want to make a very understated statement, this is the pencil for you.\n\nIf you like these pencils, the choice comes down to textured vs non-textured grip and the colour of the cap.\n\nThis is a pencil to own if you want to pay homage to the creator of the mechanical pencil.",
"images": [
"400-caran-d-ache-fixpencil-22--textured--black-body-with-red-cap.jpg",
"400-caran-d-ache-fixpencil-22--textured--black-body-with-blue-cap.jpg",
Expand Down Expand Up @@ -2052,7 +2052,7 @@
"variants": [ "Black", "Brass" ],
"colours": [ "Black", "Brass" ],
"id": 57,
"description": "",
"description": "This pencil leaves you with a feeling of comfort and delight. It is just so very well presented and prepared. If you want the full experience, buy one of these — although they are pricy, especially including shipping and taxes.\n\nYou will not be disappointed.",
"images": [
"400-ystudio-classic-revolve-black.jpg",
"400-ystudio-classic-revolve-brass.jpg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ solr.highlight=false
# panl.range.max.wildcard.<lpse_code>
# (Optional) If the maximum value acts as a wildcard (and therefore
# will also include values which are greater than this value)
# panl.range.suppress.<lpse_code>
# (Optional) By default, panl will return a range and the individual
# values for a facet. Setting this to true will only return the range
# values.
#
# ~ ~ ~ * ~ ~ ~
#
Expand Down
4 changes: 4 additions & 0 deletions src/dist/sample/panl/book-store/book-store.panl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ solr.highlight=false
# panl.range.max.wildcard.<lpse_code>
# (Optional) If the maximum value acts as a wildcard (and therefore
# will also include values which are greater than this value)
# panl.range.suppress.<lpse_code>
# (Optional) By default, panl will return a range and the individual
# values for a facet. Setting this to true will only return the range
# values.
#
# ~ ~ ~ * ~ ~ ~
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ solr.highlight=false
# panl.range.max.wildcard.<lpse_code>
# (Optional) If the maximum value acts as a wildcard (and therefore
# will also include values which are greater than this value)
# panl.range.suppress.<lpse_code>
# (Optional) By default, panl will return a range and the individual
# values for a facet. Setting this to true will only return the range
# values.
#
# ~ ~ ~ * ~ ~ ~
#
Expand Down Expand Up @@ -477,6 +481,8 @@ panl.range.min.value.w=from light
panl.range.max.value.w=heavy pencils
panl.range.min.wildcard.w=true
panl.range.max.wildcard.w=true
panl.range.suppress.w=true



# <field "indexed"="true" "stored"="true" "name"="relative_weight" "type"="pint" "multiValued"="false" />
Expand Down Expand Up @@ -525,6 +531,7 @@ panl.type.I=solr.BoolField
# <field "indexed"="true" "stored"="true" "name"="variants" "type"="string" "multiValued"="true" />
panl.field.v=variants
panl.name.v=Variants
panl.multivalue.v=true
panl.type.v=solr.StrField

# <field "indexed"="true" "stored"="true" "name"="nib_shape" "type"="string" "multiValued"="false" />
Expand Down Expand Up @@ -573,6 +580,7 @@ panl.bool.9.false=No in-built sharpener
# <field "indexed"="true" "stored"="true" "name"="colours" "type"="string" "multiValued"="true" />
panl.facet.W=colours
panl.name.W=Colours
panl.multivalue.W=true
panl.type.W=solr.StrField


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ solr.highlight=false
# panl.range.max.wildcard.<lpse_code>
# (Optional) If the maximum value acts as a wildcard (and therefore
# will also include values which are greater than this value)
# panl.range.suppress.<lpse_code>
# (Optional) By default, panl will return a range and the individual
# values for a facet. Setting this to true will only return the range
# values.
#
# ~ ~ ~ * ~ ~ ~
#
Expand Down Expand Up @@ -537,6 +541,7 @@ panl.type.I=solr.BoolField
# <field "indexed"="true" "stored"="true" "name"="variants" "type"="string" "multiValued"="true" />
panl.field.v=variants
panl.name.v=Variants
panl.multivalue.v=true
panl.type.v=solr.StrField

# <field "indexed"="true" "stored"="true" "name"="nib_shape" "type"="string" "multiValued"="false" />
Expand Down Expand Up @@ -585,6 +590,7 @@ panl.bool.9.false=No in-built sharpener
# <field "indexed"="true" "stored"="true" "name"="colours" "type"="string" "multiValued"="true" />
panl.facet.W=colours
panl.name.W=Colours
panl.multivalue.W=true
panl.type.W=solr.StrField


Expand Down
4 changes: 4 additions & 0 deletions src/dist/sample/panl/simple-date/simple-date.panl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ solr.highlight=false
# panl.range.max.wildcard.<lpse_code>
# (Optional) If the maximum value acts as a wildcard (and therefore
# will also include values which are greater than this value)
# panl.range.suppress.<lpse_code>
# (Optional) By default, panl will return a range and the individual
# values for a facet. Setting this to true will only return the range
# values.
#
# ~ ~ ~ * ~ ~ ~
#
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/synapticloop/panl/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import java.util.stream.Collectors;

/**
* <p>This is the main entry point for the PANL server/generator.</p>
* <p>This is the main class for the PANL server/generator.</p>
*/
public class Main {
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
Expand Down Expand Up @@ -78,7 +78,7 @@ public class Main {
private final String[] args;

/**
* <p>Instantiate the Main</p>
* <p>Instantiate the main class.</p>
*
* @param args The command line arguments
*/
Expand Down Expand Up @@ -141,11 +141,12 @@ private void parseAndExecuteCommandLine() throws PanlServerException, CommandLin
*
* @throws PanlServerException If there was an error starting the server
* @throws CommandLineOptionException If there was an error with the command
* line options
* line options
*/
private void parseAndExecuteServerCommands() throws PanlServerException, CommandLineOptionException {
this.propertiesFileLocation = OPTIONS_MAP.getOrDefault(CMD_OPTION_PROPERTIES, DEFAULT_PANL_PROPERTIES);
String portNumberString = OPTIONS_MAP.getOrDefault(CMD_OPTION_PORT, DEFAULT_PORT_NUMBER);

try {
this.portNumber = Integer.parseInt(portNumberString);
} catch (NumberFormatException e) {
Expand Down Expand Up @@ -237,7 +238,9 @@ private void usageAndException(String message) throws CommandLineOptionException
}

/**
* <p>Main starting point for the application.</p>
* <p>Main starting point for the application, parsing the command line
* options and executing the required component. If there was an error when
* parsing the options then it will print out an error message and exit.</p>
*
* @param args The arguments to parse
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,24 +339,44 @@ private String parseResponse(

panlObject.put(JSON_KEY_AVAILABLE, availableProcessor.processToObject(panlTokenMap, response));

// now we are going to add the dynamic range if they exist
JSONObject statsObject = solrJsonObject.optJSONObject("stats");
if(null != statsObject) {
JSONObject statsFieldObjects = statsObject.optJSONObject("stats_fields");
if (null != statsFieldObjects) {
JSONArray jsonArray = panlObject.getJSONObject(JSON_KEY_AVAILABLE).getJSONArray(Processor.JSON_KEY_RANGE_FACETS);
for (Object object : jsonArray) {
JSONObject rangeObject = (JSONObject) object;
String facetName = rangeObject.getString("facet_name");
if(null != statsFieldObjects.optJSONObject(facetName, null)) {
rangeObject.put(JSON_KEY_DYNAMIC_MIN, statsFieldObjects.getJSONObject(facetName).getInt("min"));
rangeObject.put(JSON_KEY_DYNAMIC_MAX, statsFieldObjects.getJSONObject(facetName).getInt("max"));
if(null != statsFieldObjects) {
Iterator<String> keys = statsFieldObjects.keys();
while(keys.hasNext()) {
String key = keys.next();
JSONObject valueObject = statsFieldObjects.getJSONObject(key);
// now that we have the value, go through the range facets and get the right one.
JSONArray jsonArray = panlObject.getJSONObject(JSON_KEY_AVAILABLE).getJSONArray(Processor.JSON_KEY_RANGE_FACETS);
for(Object object : jsonArray) {
JSONObject rangeObject = (JSONObject) object;
if(rangeObject.getString("facet_name").equals(key)) {
rangeObject.put(JSON_KEY_DYNAMIC_MIN, valueObject.optInt("min", -1));
rangeObject.put(JSON_KEY_DYNAMIC_MAX, valueObject.optInt("max", -1));
}
}
}
}
}

solrJsonObject.remove("stats");

// now we need to go through the range facets and remove any that are
// suppressed

JSONArray removedRanges = new JSONArray();
for (Object jsonObject : panlObject.getJSONObject(JSON_KEY_AVAILABLE).getJSONArray(Processor.JSON_KEY_FACETS)) {
JSONObject facetObject = (JSONObject) jsonObject;
String lpseCode = facetObject.getString(Processor.JSON_KEY_PANL_CODE);
if(!collectionProperties.getIsSuppressedRangeFacet(lpseCode)) {
removedRanges.put(facetObject);
}
}

panlObject.getJSONObject(JSON_KEY_AVAILABLE).put(Processor.JSON_KEY_FACETS, removedRanges);



panlObject.put(JSON_KEY_ACTIVE, activeProcessor.processToObject(panlTokenMap));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ protected JSONObject getAdditionURIObject(CollectionProperties collectionPropert
if (baseField.getLpseCode().equals(additionLpseCode)) {

additionObject.put(JSON_KEY_BEFORE, lpseUri.toString() + baseField.getResetUriPath(panlTokenMap, collectionProperties));
// additionObject.put(JSON_KEY_BEFORE, baseField.getResetUriPath(panlTokenMap, collectionProperties));

lpseUri.setLength(0);
lpseCode.append(baseField.getResetLpseCode(panlTokenMap, collectionProperties));
lpseCode.append(baseField.getLpseCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public PanlOrFacetField(String lpseCode, String propertyKey, Properties properti
}

@Override protected void applyToQueryInternal(SolrQuery solrQuery, List<LpseToken> lpseTokenList) {
// if there is only one...
// if there is only one... no need to do anything different
if (lpseTokenList.size() == 1) {
OrFacetLpseToken facetLpseToken = (OrFacetLpseToken) lpseTokenList.get(0);

Expand All @@ -94,7 +94,7 @@ public PanlOrFacetField(String lpseCode, String propertyKey, Properties properti

StringBuilder stringBuilder = new StringBuilder();
boolean isFirst = true;
// at this point, we are going through the or filters
// at this point, we are going through the OR filters
for (LpseToken lpseToken : lpseTokenList) {
OrFacetLpseToken orFacetLpseToken = (OrFacetLpseToken) lpseToken;
if (isFirst) {
Expand Down Expand Up @@ -199,6 +199,7 @@ public PanlOrFacetField(String lpseCode, String propertyKey, Properties properti
return (true);
}
}

return (false);
}

Expand Down
Loading

0 comments on commit 23f5815

Please sign in to comment.