-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate search set maxFieldLength lucene property
PostPosted: Tue May 20, 2008 11:22 am 
Newbie

Joined: Tue May 20, 2008 11:14 am
Posts: 7
Hello,
I'm using hibernate search in on of my java project and I need some help.
I've seen that you can configure some Lucene properties into the hibernate config file like maxMergeDocs,...
But is not possible to set the maxFieldLength lucene property.
How can I manage this?
Thanks in advence.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 5:33 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

it seems that this property is just not exposed yet. I guess no one really needed it so far. I created a Jira issue for it - http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-200.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 22, 2008 11:58 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I've attached a patch to Hardy's Jira, it contains documentation updates as well
(apply it to trunk).
you could try it if you like, but would suggest against setting different parameters
for the batch and transaction sections; the final version of the patch will log something about it or avoid it.

Do you think there could be some good reason to set the two parameters differently?

regards,

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 23, 2008 6:35 am 
Newbie

Joined: Tue May 20, 2008 11:14 am
Posts: 7
I had to change the source to adapt this property like this:


1. src\org\hibernate\search\backend\Workspace.java
• public IndexWriter getIndexWriter() ... writer.setMaxFieldLength(indexingParams.getBatchMaxFieldLenght() );


2. src\org\hibernate\search\backend\LuceneIndexingParameters.java
• private static final int DEFAULT_MAX_FIELD_LENGHT = IndexWriter.DEFAULT_MAX_FIELD_LENGTH;
• private static final int MAX_FIELD_LENGHT = Integer.MAX_VALUE;
• public LuceneIndexingParameters() ...
batchMaxFieldLenght = DEFAULT_MAX_FIELD_LENGHT;
• public int getBatchMaxFieldLenght() {
if (batchMaxFieldLenght < 0) {
batchMaxFieldLenght = MAX_FIELD_LENGHT;
}
return batchMaxFieldLenght;
}

public void setBatchMaxFieldLenght(int batchMaxFieldLenght) {
this.batchMaxFieldLenght = batchMaxFieldLenght;
}



3. src\org\hibernate\search\store\DirectoryProviderFactory.java
• private static final String MAX_FIELD_LENGTH = "max_field_length";
• private void configureIndexingParameter(...) -----
s = indexProps.getProperty(BATCH + MAX_FIELD_LENGTH);
if (!StringHelper.isEmpty( s )) {
try{
indexingParams.setBatchMaxFieldLenght(Integer.valueOf(s));
} catch (NumberFormatException ne) {
throw new SearchException("Invalid value for " + BATCH + MAX_FIELD_LENGTH + ": " + s);
}
}


Compile source and use the new jar file in your project and add this property to your cfg file:
<property name="hibernate.search.default.batch.max_field_length">
-1
</property>

If not set the default value is set, if it's a negatif number value is Integer.MAXVALUE otherwise set with the written value.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 23, 2008 6:49 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
very nice you tried!
I don't really undertand your code without formatting and line numbers, but it looks like you've complicated it a bit, you didn't try my patch?

a part from the huge documentation update, you have to add just three lines of code;

just add this:
Code:
MAX_FIELD_LENGTH( "max_field_length" ) {
      public void applySetting(IndexWriter writer, int value) {
         writer.setMaxFieldLength( value );
      }
   } ,

to the IndexWriterSetting enum types.


Also I woudn't recommend to set the defaults to MAX_INTEGER; with the above patch you get the lucene defaults when not setting anything.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.