[jira] Updated: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser
[ https://issues.apache.org/jira/browse/LUCENE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simon Willnauer updated LUCENE-2039: Attachment: LUCENE-2039_field_ext.patch This patch implements the field:ext: approach. I will do some more work on the javadoc - pushing it out for comments! Comments on class naming are welcome too :) > Regex support and beyond in JavaCC QueryParser > -- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser >Reporter: Simon Willnauer >Assignee: Grant Ingersoll >Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch > > > Since the early days the standard query parser was limited to the queries > living in core, adding other queries or extending the parser in any way > always forced people to change the grammar file and regenerate. Even if you > change the grammar you have to be extremely careful how you modify the parser > so that other parts of the standard parser are affected by customisation > changes. Eventually you had to live with all the limitation the current > parser has like tokenizing on whitespaces before a tokenizer / analyzer has > the chance to look at the tokens. > I was thinking about how to overcome the limitation and add regex support to > the query parser without introducing any dependency to core. I added a new > special character that basically prevents the parser from interpreting any of > the characters enclosed in the new special characters. I choose the forward > slash '/' as the delimiter so that everything in between two forward slashes > is basically escaped and ignored by the parser. All chars embedded within > forward slashes are treated as one token even if it contains other special > chars like * []?{} or whitespaces. This token is subsequently passed to a > pluggable "parser extension" with builds a query from the embedded string. I > do not interpret the embedded string in any way but leave all the subsequent > work to the parser extension. Such an extension could be another full > featured query parser itself or simply a ctor call for regex query. The > interface remains quiet simple but makes the parser extendible in an easy way > compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special char > into the syntax but I guess that would not be that much of a deal as it is > reflected in the escape method though. It would truly be nice to have more > than once extension an have this even more flexible so treat this patch as a > kickoff though. > Another way of solving the problem with RegexQuery would be to move the JDK > version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ... > } > {code} > which I would like better as it would be more consistent with the idea of the > query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based > approach I guess I will add a second patch with regex in core soon too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. - To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org
[jira] Updated: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser
[ https://issues.apache.org/jira/browse/LUCENE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simon Willnauer updated LUCENE-2039: Attachment: LUCENE-2039_field_ext.patch Updated the patch - removed final modifier from ExtendableQueryParser - added RegexCapabilities ctor to RegexParserExtension I still need to work on the Extensions JavaDoc - and I'm not too happy with the name. Comments on the concept are very welcome. > Regex support and beyond in JavaCC QueryParser > -- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser >Reporter: Simon Willnauer >Assignee: Grant Ingersoll >Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch > > > Since the early days the standard query parser was limited to the queries > living in core, adding other queries or extending the parser in any way > always forced people to change the grammar file and regenerate. Even if you > change the grammar you have to be extremely careful how you modify the parser > so that other parts of the standard parser are affected by customisation > changes. Eventually you had to live with all the limitation the current > parser has like tokenizing on whitespaces before a tokenizer / analyzer has > the chance to look at the tokens. > I was thinking about how to overcome the limitation and add regex support to > the query parser without introducing any dependency to core. I added a new > special character that basically prevents the parser from interpreting any of > the characters enclosed in the new special characters. I choose the forward > slash '/' as the delimiter so that everything in between two forward slashes > is basically escaped and ignored by the parser. All chars embedded within > forward slashes are treated as one token even if it contains other special > chars like * []?{} or whitespaces. This token is subsequently passed to a > pluggable "parser extension" with builds a query from the embedded string. I > do not interpret the embedded string in any way but leave all the subsequent > work to the parser extension. Such an extension could be another full > featured query parser itself or simply a ctor call for regex query. The > interface remains quiet simple but makes the parser extendible in an easy way > compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special char > into the syntax but I guess that would not be that much of a deal as it is > reflected in the escape method though. It would truly be nice to have more > than once extension an have this even more flexible so treat this patch as a > kickoff though. > Another way of solving the problem with RegexQuery would be to move the JDK > version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ... > } > {code} > which I would like better as it would be more consistent with the idea of the > query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based > approach I guess I will add a second patch with regex in core soon too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. - To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org
[jira] Updated: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser
[ https://issues.apache.org/jira/browse/LUCENE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simon Willnauer updated LUCENE-2039: Attachment: LUCENE-2039_field_ext.patch moved ext parser to contrib/misc > Regex support and beyond in JavaCC QueryParser > -- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser >Reporter: Simon Willnauer >Assignee: Grant Ingersoll >Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch, LUCENE-2039_field_ext.patch > > > Since the early days the standard query parser was limited to the queries > living in core, adding other queries or extending the parser in any way > always forced people to change the grammar file and regenerate. Even if you > change the grammar you have to be extremely careful how you modify the parser > so that other parts of the standard parser are affected by customisation > changes. Eventually you had to live with all the limitation the current > parser has like tokenizing on whitespaces before a tokenizer / analyzer has > the chance to look at the tokens. > I was thinking about how to overcome the limitation and add regex support to > the query parser without introducing any dependency to core. I added a new > special character that basically prevents the parser from interpreting any of > the characters enclosed in the new special characters. I choose the forward > slash '/' as the delimiter so that everything in between two forward slashes > is basically escaped and ignored by the parser. All chars embedded within > forward slashes are treated as one token even if it contains other special > chars like * []?{} or whitespaces. This token is subsequently passed to a > pluggable "parser extension" with builds a query from the embedded string. I > do not interpret the embedded string in any way but leave all the subsequent > work to the parser extension. Such an extension could be another full > featured query parser itself or simply a ctor call for regex query. The > interface remains quiet simple but makes the parser extendible in an easy way > compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special char > into the syntax but I guess that would not be that much of a deal as it is > reflected in the escape method though. It would truly be nice to have more > than once extension an have this even more flexible so treat this patch as a > kickoff though. > Another way of solving the problem with RegexQuery would be to move the JDK > version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ... > } > {code} > which I would like better as it would be more consistent with the idea of the > query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based > approach I guess I will add a second patch with regex in core soon too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. - To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org
[jira] Updated: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser
[ https://issues.apache.org/jira/browse/LUCENE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simon Willnauer updated LUCENE-2039: Attachment: LUCENE-2039_field_ext.patch I finished the JavaDoc, added package.html file. I again refactored RegexParserExtension to use a factory method to obtain an instance of RegexCapabilities. RegexCapabilities is stateful and can not be shared so subclassing to change seems to be reasonable. JavaUtil seems to be reasonable anyway after the latest Jakarta Regexp drama :). I had to introduce a compile time dependency from regex to misc to build the extension - should add misc as a dependency to maven in this case? > Regex support and beyond in JavaCC QueryParser > -- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser >Reporter: Simon Willnauer >Assignee: Simon Willnauer >Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch > > > Since the early days the standard query parser was limited to the queries > living in core, adding other queries or extending the parser in any way > always forced people to change the grammar file and regenerate. Even if you > change the grammar you have to be extremely careful how you modify the parser > so that other parts of the standard parser are affected by customisation > changes. Eventually you had to live with all the limitation the current > parser has like tokenizing on whitespaces before a tokenizer / analyzer has > the chance to look at the tokens. > I was thinking about how to overcome the limitation and add regex support to > the query parser without introducing any dependency to core. I added a new > special character that basically prevents the parser from interpreting any of > the characters enclosed in the new special characters. I choose the forward > slash '/' as the delimiter so that everything in between two forward slashes > is basically escaped and ignored by the parser. All chars embedded within > forward slashes are treated as one token even if it contains other special > chars like * []?{} or whitespaces. This token is subsequently passed to a > pluggable "parser extension" with builds a query from the embedded string. I > do not interpret the embedded string in any way but leave all the subsequent > work to the parser extension. Such an extension could be another full > featured query parser itself or simply a ctor call for regex query. The > interface remains quiet simple but makes the parser extendible in an easy way > compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special char > into the syntax but I guess that would not be that much of a deal as it is > reflected in the escape method though. It would truly be nice to have more > than once extension an have this even more flexible so treat this patch as a > kickoff though. > Another way of solving the problem with RegexQuery would be to move the JDK > version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ... > } > {code} > which I would like better as it would be more consistent with the idea of the > query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based > approach I guess I will add a second patch with regex in core soon too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. - To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org
[jira] Updated: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser
[ https://issues.apache.org/jira/browse/LUCENE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simon Willnauer updated LUCENE-2039: Attachment: LUCENE-2039_field_ext.patch I removed the RegexExtension in this patch as in my opinion this is not worth the dependency. As soon as roberts automation patch is in core we won't have this problem anymore anyway. Users should add trivial extensions like on their own. One other thing I was thinking about is adding another ExtensionParser which subclasses ComplexPhraseQueryParser. This is a benefit from moving it into misc, I think we should do it. Thoughts? > Regex support and beyond in JavaCC QueryParser > -- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser >Reporter: Simon Willnauer >Assignee: Simon Willnauer >Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch, LUCENE-2039_field_ext.patch > > > Since the early days the standard query parser was limited to the queries > living in core, adding other queries or extending the parser in any way > always forced people to change the grammar file and regenerate. Even if you > change the grammar you have to be extremely careful how you modify the parser > so that other parts of the standard parser are affected by customisation > changes. Eventually you had to live with all the limitation the current > parser has like tokenizing on whitespaces before a tokenizer / analyzer has > the chance to look at the tokens. > I was thinking about how to overcome the limitation and add regex support to > the query parser without introducing any dependency to core. I added a new > special character that basically prevents the parser from interpreting any of > the characters enclosed in the new special characters. I choose the forward > slash '/' as the delimiter so that everything in between two forward slashes > is basically escaped and ignored by the parser. All chars embedded within > forward slashes are treated as one token even if it contains other special > chars like * []?{} or whitespaces. This token is subsequently passed to a > pluggable "parser extension" with builds a query from the embedded string. I > do not interpret the embedded string in any way but leave all the subsequent > work to the parser extension. Such an extension could be another full > featured query parser itself or simply a ctor call for regex query. The > interface remains quiet simple but makes the parser extendible in an easy way > compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special char > into the syntax but I guess that would not be that much of a deal as it is > reflected in the escape method though. It would truly be nice to have more > than once extension an have this even more flexible so treat this patch as a > kickoff though. > Another way of solving the problem with RegexQuery would be to move the JDK > version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ... > } > {code} > which I would like better as it would be more consistent with the idea of the > query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based > approach I guess I will add a second patch with regex in core soon too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. - To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org
[jira] Updated: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser
[ https://issues.apache.org/jira/browse/LUCENE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simon Willnauer updated LUCENE-2039: Attachment: LUCENE-2039_wrap_master_parser.patch David here is an example of what I mean by wrapping the top level parser. This would give you access to all the settings right away inside your extension. > Regex support and beyond in JavaCC QueryParser > -- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser >Reporter: Simon Willnauer >Assignee: Simon Willnauer >Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_field_ext.patch, LUCENE-2039_field_ext.patch, > LUCENE-2039_wrap_master_parser.patch > > > Since the early days the standard query parser was limited to the queries > living in core, adding other queries or extending the parser in any way > always forced people to change the grammar file and regenerate. Even if you > change the grammar you have to be extremely careful how you modify the parser > so that other parts of the standard parser are affected by customisation > changes. Eventually you had to live with all the limitation the current > parser has like tokenizing on whitespaces before a tokenizer / analyzer has > the chance to look at the tokens. > I was thinking about how to overcome the limitation and add regex support to > the query parser without introducing any dependency to core. I added a new > special character that basically prevents the parser from interpreting any of > the characters enclosed in the new special characters. I choose the forward > slash '/' as the delimiter so that everything in between two forward slashes > is basically escaped and ignored by the parser. All chars embedded within > forward slashes are treated as one token even if it contains other special > chars like * []?{} or whitespaces. This token is subsequently passed to a > pluggable "parser extension" with builds a query from the embedded string. I > do not interpret the embedded string in any way but leave all the subsequent > work to the parser extension. Such an extension could be another full > featured query parser itself or simply a ctor call for regex query. The > interface remains quiet simple but makes the parser extendible in an easy way > compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special char > into the syntax but I guess that would not be that much of a deal as it is > reflected in the escape method though. It would truly be nice to have more > than once extension an have this even more flexible so treat this patch as a > kickoff though. > Another way of solving the problem with RegexQuery would be to move the JDK > version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ... > } > {code} > which I would like better as it would be more consistent with the idea of the > query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based > approach I guess I will add a second patch with regex in core soon too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. - To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org