Re: I need to indexing the first character of a field in another field

2010-10-19 Thread Renato Wesenauer
Hi guys,

I read all suggestions and I did some tests, and finally, the indexing
process is working.

I did the extraction of initial character of three fields. Here are the
functions:

function extraiInicial(valor) {
  if (valor !=   valor != null) {
  valor = valor.substring(0, 1).toUpperCase();
  }
  else {
  valor = '';
  }
  return valor;
}

function extraiIniciaisAutorEditoraSebo(linha) {

linha.put(inicialautor, extraiInicial(linha.get(autor)));
linha.put(inicialeditora,
extraiInicial(linha.get(editora)));
linha.put(inicialsebo,
extraiInicial(linha.get(sebo)));
return linha;
}

Thank you for your help,

Renato F. Wesenauer




2010/10/18 Chris Hostetter hossman_luc...@fucit.org


 This exact topic was just discussed a few days ago...


 http://search.lucidimagination.com/search/document/7b6e2cc37bbb95c8/faceting_and_first_letter_of_fields#3059a28929451cb4

 My comments on when/where it makes sense to put this logic...


 http://search.lucidimagination.com/search/document/7b6e2cc37bbb95c8/faceting_and_first_letter_of_fields#7b6e2cc37bbb95c8


 : Date: Mon, 18 Oct 2010 19:31:28 -0200
 : From: Renato Wesenauer renato.wesena...@gmail.com
 : Reply-To: solr-user@lucene.apache.org
 : To: solr-user@lucene.apache.org
 : Subject: I need to indexing the first character of a field in another
 field
 :
 : Hello guys,
 :
 : I need to indexing the first character of the field autor in another
 field
 : inicialautor.
 : Example:
 :autor = Mark Webber
 :inicialautor = M
 :
 : I did a javascript function in the dataimport, but the field
  inicialautor
 : indexing empty.
 :
 : The function:
 :
 : function InicialAutor(linha) {
 : var aut = linha.get(autor);
 : if (aut != null) {
 :   if (aut.length  0) {
 :   var ch = aut.charAt(0);
 :   linha.put(inicialautor, ch);
 :   }
 :   else {
 :   linha.put(inicialautor, '');
 :   }
 : }
 : else {
 : linha.put(inicialautor, '');
 : }
 : return linha;
 : }
 :
 : What's wrong?
 :
 : Thank's,
 :
 : Renato Wesenauer
 :

 -Hoss



I need to indexing the first character of a field in another field

2010-10-18 Thread Renato Wesenauer
Hello guys,

I need to indexing the first character of the field autor in another field
inicialautor.
Example:
   autor = Mark Webber
   inicialautor = M

I did a javascript function in the dataimport, but the field  inicialautor
indexing empty.

The function:

function InicialAutor(linha) {
var aut = linha.get(autor);
if (aut != null) {
  if (aut.length  0) {
  var ch = aut.charAt(0);
  linha.put(inicialautor, ch);
  }
  else {
  linha.put(inicialautor, '');
  }
}
else {
linha.put(inicialautor, '');
}
return linha;
}

What's wrong?

Thank's,

Renato Wesenauer


Re: I need to indexing the first character of a field in another field

2010-10-18 Thread Ezequiel Calderara
How are you declaring the transformer in the dataconfig?

On Mon, Oct 18, 2010 at 6:31 PM, Renato Wesenauer 
renato.wesena...@gmail.com wrote:

 Hello guys,

 I need to indexing the first character of the field autor in another
 field
 inicialautor.
 Example:
   autor = Mark Webber
   inicialautor = M

 I did a javascript function in the dataimport, but the field  inicialautor
 indexing empty.

 The function:

function InicialAutor(linha) {
var aut = linha.get(autor);
if (aut != null) {
  if (aut.length  0) {
  var ch = aut.charAt(0);
  linha.put(inicialautor, ch);
  }
  else {
  linha.put(inicialautor, '');
  }
}
else {
linha.put(inicialautor, '');
}
return linha;
}

 What's wrong?

 Thank's,

 Renato Wesenauer




-- 
__
Ezequiel.

Http://www.ironicnet.com


Re: I need to indexing the first character of a field in another field

2010-10-18 Thread Pradeep Singh
You can use regular expression based template transformer without writing a
separate function. It's pretty easy to use.

On Mon, Oct 18, 2010 at 2:31 PM, Renato Wesenauer 
renato.wesena...@gmail.com wrote:

 Hello guys,

 I need to indexing the first character of the field autor in another
 field
 inicialautor.
 Example:
   autor = Mark Webber
   inicialautor = M

 I did a javascript function in the dataimport, but the field  inicialautor
 indexing empty.

 The function:

function InicialAutor(linha) {
var aut = linha.get(autor);
if (aut != null) {
  if (aut.length  0) {
  var ch = aut.charAt(0);
  linha.put(inicialautor, ch);
  }
  else {
  linha.put(inicialautor, '');
  }
}
else {
linha.put(inicialautor, '');
}
return linha;
}

 What's wrong?

 Thank's,

 Renato Wesenauer



Re: I need to indexing the first character of a field in another field

2010-10-18 Thread Jonathan Rochkind
You can just do this with a copyfield in your schema.xml instead.  Copy 
to a field which uses regexpfilter or some other analyzer to limit to 
first non-whitespace char (and perhaps force upcase too if you want). 
That's what I'd do, easier and will work if you index to Solr from 
something other than dataimport as well.


Renato Wesenauer wrote:

Hello guys,

I need to indexing the first character of the field autor in another field
inicialautor.
Example:
   autor = Mark Webber
   inicialautor = M

I did a javascript function in the dataimport, but the field  inicialautor
indexing empty.

The function:

function InicialAutor(linha) {
var aut = linha.get(autor);
if (aut != null) {
  if (aut.length  0) {
  var ch = aut.charAt(0);
  linha.put(inicialautor, ch);
  }
  else {
  linha.put(inicialautor, '');
  }
}
else {
linha.put(inicialautor, '');
}
return linha;
}

What's wrong?

Thank's,

Renato Wesenauer

  


Re: I need to indexing the first character of a field in another field

2010-10-18 Thread Chris Hostetter

This exact topic was just discussed a few days ago...

http://search.lucidimagination.com/search/document/7b6e2cc37bbb95c8/faceting_and_first_letter_of_fields#3059a28929451cb4

My comments on when/where it makes sense to put this logic...

http://search.lucidimagination.com/search/document/7b6e2cc37bbb95c8/faceting_and_first_letter_of_fields#7b6e2cc37bbb95c8


: Date: Mon, 18 Oct 2010 19:31:28 -0200
: From: Renato Wesenauer renato.wesena...@gmail.com
: Reply-To: solr-user@lucene.apache.org
: To: solr-user@lucene.apache.org
: Subject: I need to indexing the first character of a field in another field
: 
: Hello guys,
: 
: I need to indexing the first character of the field autor in another field
: inicialautor.
: Example:
:autor = Mark Webber
:inicialautor = M
: 
: I did a javascript function in the dataimport, but the field  inicialautor
: indexing empty.
: 
: The function:
: 
: function InicialAutor(linha) {
: var aut = linha.get(autor);
: if (aut != null) {
:   if (aut.length  0) {
:   var ch = aut.charAt(0);
:   linha.put(inicialautor, ch);
:   }
:   else {
:   linha.put(inicialautor, '');
:   }
: }
: else {
: linha.put(inicialautor, '');
: }
: return linha;
: }
: 
: What's wrong?
: 
: Thank's,
: 
: Renato Wesenauer
: 

-Hoss