cancel
Showing results for 
Search instead for 
Did you mean: 

Indexation problem

flin
Champ in-the-making
Champ in-the-making
Hi there,

I'm adding a content through code to the repository, and then I try to search it using lucene but I have no results. Using "nint" as search string I can see that is was not indexed.

My code:
         Node node2 = this.session.getRootNode();Node child = node2.addNode("testeindex5", "cm:content");child.setProperty("cm:title", "My test");child.setProperty("cm:content", "Just a test content.");‍‍‍‍‍‍

Query:
String query = "PATH:\"//*\" AND TEXT:\"Just\" ";StoreRef sr = new StoreRef("workspace", "SpacesStore");SearchParameters sp = new SearchParameters();sp.addStore(sr);sp.setLanguage(SearchService.LANGUAGE_LUCENE);sp.setQuery(query);‍‍‍‍‍‍‍‍‍‍

Then I'm getting the ResultSet using:
serviceRegistry.getSearchService().query(sp);


I'm using the latest Alfresco version (yesterday checkout from HEAD)

Why my new content is not being indexed?
2 REPLIES 2

flin
Champ in-the-making
Champ in-the-making
Another test was made using a code similar to the way Alfresco webclient creates content and it didn't work as well Smiley Sad

   public void saveContent(String strContent) throws Exception {      // get the node ref of the node that will contain the content      NodeRef containerNodeRef = JCRNodeRef            .getNodeRef(getNode("/"));      FileInfo fileInfo = this.serviceRegistry.getFileFolderService().create(            containerNodeRef,            "myTesteFileContent",            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,                  "content"));      NodeRef fileNodeRef = fileInfo.getNodeRef();      // set the author aspect      Map<QName, Serializable> authorProps = new HashMap<QName, Serializable>(            1, 1.0f);      authorProps.put(ContentModel.PROP_AUTHOR, "fabio");      this.serviceRegistry.getNodeService().addAspect(fileNodeRef,            ContentModel.ASPECT_AUTHOR, authorProps);      // apply the titled aspect - title and description      Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(            3, 1.0f);      titledProps.put(ContentModel.PROP_TITLE, "teste title");      titledProps.put(ContentModel.PROP_DESCRIPTION, "teste desc");      this.serviceRegistry.getNodeService().addAspect(fileNodeRef,            ContentModel.ASPECT_TITLED, titledProps);      // get a writer for the content and put the file      ContentWriter writer = this.serviceRegistry.getContentService()            .getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);      // set the mimetype and encoding      writer.setMimetype("plain/text");      writer.setEncoding("UTF-8");      writer.putContent(strContent == null ? "" : strContent);   }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

flin
Champ in-the-making
Champ in-the-making
Ha, using alfresco web code it works. The problem of the above code was the mime type.
Should be writer.setMimetype("text/plain"); not plain/text.

But using only JCR API it does not work still Smiley Sad