Giter Site home page Giter Site logo

Comments (2)

kalhomoud avatar kalhomoud commented on August 22, 2024

Hi @paulcappadona,
Could you please elaborate? Can you give me an example?

Thanks!

from committer-elasticsearch.

paulcappadona avatar paulcappadona commented on August 22, 2024

Hi @kalhomoud

The method in question should be matching document metadata field names against a regex pattern, and if matching return true so that the committer processes the data as a JSON object (not a string).

The following code illustrates that the match method should be issued against the field, not the regex pattern

	/**
	 * Attempting to match any fields beginning with "obj-" so they are treated as JSON objects
	 */
	public static void main(String[] args) {
		String pattern = "^" + "obj-" + ".*$";
		// Expected match result is true for the following
		testField("obj-crawl-meta", pattern);
		testField("obj-document-meta", pattern);
		// Expected no match, so false
		testField("somefield", pattern);
	}
	
	private static void testField(String field, String pattern) {
		// this is the logic in the ElasticSearchCommitter
		System.out.println("Matching (pattern.match(field)) pattern " + pattern + " against field " + field + " : Matched = " + pattern.matches(field));
		// this is the correct logic
		System.out.println("Matching (field.match(pattern)) field " + field + " against pattern " + pattern + " : Matched = " + field.matches(pattern));
	}

The output of this code is
// Expected match (true)
Matching (pattern.match(field)) pattern ^obj-.$ against field obj-crawl-meta : Matched = false
Matching (field.match(pattern)) field obj-crawl-meta against pattern ^obj-.
$ : Matched = true
Matching (pattern.match(field)) pattern ^obj-.$ against field obj-document-meta : Matched = false
Matching (field.match(pattern)) field obj-document-meta against pattern ^obj-.
$ : Matched = true
// Expected fail (false)
Matching (pattern.match(field)) pattern ^obj-.$ against field somefield : Matched = false
Matching (field.match(pattern)) field somefield against pattern ^obj-.
$ : Matched = false

Regards
Paul

from committer-elasticsearch.

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.