cancel
Showing results for 
Search instead for 
Did you mean: 

Search by TEXT with Lucene

spilby
Confirmed Champ
Confirmed Champ
Hi,

I have implemented with Java and Alfresco's Api some methods to upload files.

When I search by text (TEXT:\"text") in pdf files there are no problem. But when I search in txt files, Alfresco don't give me results. I search it with the web client, and with the node browser too, but the search with txt files don't work. The only difference between the pdf and the txt files is the content type: application/pdf vs. plain/text

Anyone knows what's the problem? The search works different with txt and pdf files? When I upload a txt file with the alfresco api, the search works. This problem only occurs when I upload the txt with my methods. But the pdf works! And are the same methods. I don't understand Smiley Surprised(

I put here the most important metadata of both files. First, uploading with alfresco web client. The second with my methods.

{http://www.alfresco.org/model/content/1.0}name   expediente 2.txt
{http://www.alfresco.org/model/system/1.0}node-dbid   1953
{http://www.alfresco.org/model/system/1.0}store-identifier   SpacesStore
{http://www.alfresco.org/model/system/1.0}node-uuid   c7dae1de-1231-4b66-9e52-2e15739215d0
{http://www.alfresco.org/model/content/1.0}content                   contentUrl=store://2010/11/8/18/56/9862e934-e320-4748-a139-ae3a9bcf4c16.bin|mimetype=text/plain|size=44|encoding=UTF-8|locale=en_US_
{http://www.alfresco.org/model/content/1.0}title   expediente 2.txt
{http://www.alfresco.org/model/system/1.0}store-protocol   workspace

———-

{http://www.alfresco.org/model/content/1.0}name   UDS B2.txt
{http://www.alfresco.org/model/system/1.0}node-dbid   1954
{http://www.alfresco.org/model/system/1.0}store-identifier   SpacesStore
{http://www.alfresco.org/model/system/1.0}node-uuid   ad5c00f1-1900-4c2c-b9c9-1e90e8eeabd0
{http://www.alfresco.org/model/content/1.0}content                   contentUrl=store://2010/11/8/19/4/2603c9f8-03a4-4710-9080-55ae67919b3a.bin|mimetype=text/plain|size=44|encoding=UTF-8|locale=es_ES_
{http://www.alfresco.org/model/system/1.0}store-protocol   workspace
{http://www.alfresco.org/model/content/1.0}doc_extension
{http://www.alfresco.org/model/content/1.0}doc_contentType   text/plain

Thanks!
5 REPLIES 5

smicyk
Champ in-the-making
Champ in-the-making
Hi,

code for your method would be more helpful. So someone can find how do you do it or even to reproduce the problem on its own machine.

Thanks,
smicyk

spilby
Confirmed Champ
Confirmed Champ
Oks, here's my code:

RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

String contentData = AlfrescoContentUtils.putContent(file, fileNameAlfresco);

Reference ref = new Reference(store, cmFile.getId(), null);
Predicate predicate = new Predicate(new Reference[] { ref }, null, null);

NamedValue[] fileProperties = AlfrescoServiceHelper.getFileNodeProperties(contentData, cmFile);

CMLUpdate update = new CMLUpdate(fileProperties, predicate, null);
CML cml = new CML();
cml.setUpdate(new CMLUpdate[] { update });

UpdateResult[] updateResult = repositoryService.update(cml);


And this method:

public static NamedValue[] getFileNodeProperties(String content, CMFile cmFile) {

ArrayList<NamedValue> propertiesArray = new ArrayList<NamedValue>();

propertiesArray.add(Utils.createNamedValue(Constants.PROP_CONTENT, content));
propertiesArray.add(Utils.createNamedValue(ArchivoConstants.DOC_EXTENSION, cmFile.getExtension()));
propertiesArray.add(Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}doc_contentType", cmFile.getContentType()));
propertiesArray.add(Utils.createNamedValue(Constants.PROP_NAME, cmFile.getName() + "." + cmFile.getExtension()));

NamedValue[] properties = new NamedValue[propertiesArray.size()];
return propertiesArray.toArray(properties);
}

mrogers
Star Contributor
Star Contributor
As well as different mime types you also have one document in English and one in Spanish.

spilby
Confirmed Champ
Confirmed Champ
As well as different mime types you also have one document in English and one in Spanish.

But if I search a word with international characters (for example, "hello"), why this search depends of language? Is possible? My problem is that I don't know how can I specify the language in my code, because I need to use the putContent webservice, and I can't find a NamedValue properties for the language. Anyone knows about this, please?

My code:


RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

String contentData = AlfrescoContentUtils.putContent(file, fileNameAlfresco);

Reference ref = new Reference(store, cmFile.getId(), null);
Predicate predicate = new Predicate(new Reference[] { ref }, null, null);

NamedValue[] fileProperties = AlfrescoServiceHelper.getFileNodeProperties(contentData, cmFile);

CMLUpdate update = new CMLUpdate(fileProperties, predicate, null);
CML cml = new CML();
cml.setUpdate(new CMLUpdate[] { update });

UpdateResult[] updateResult = repositoryService.update(cml);


And this method:

public static NamedValue[] getFileNodeProperties(String content, CMFile cmFile) {

ArrayList<NamedValue> propertiesArray = new ArrayList<NamedValue>();

propertiesArray.add(Utils.createNamedValue(Constants.PROP_CONTENT, content));
propertiesArray.add(Utils.createNamedValue(ArchivoConstants.DOC_EXTENSION, cmFile.getExtension()));
propertiesArray.add(Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}doc_contentType", cmFile.getContentType()));
propertiesArray.add(Utils.createNamedValue(Constants.PROP_NAME, cmFile.getName() + "." + cmFile.getExtension()));

NamedValue[] properties = new NamedValue[propertiesArray.size()];
return propertiesArray.toArray(properties);
}

tracyk859
Champ in-the-making
Champ in-the-making
Thanks for the post.
Hi guys, Im a newbie. Nice to join this forum.