Hi everyone,

I am new to using Mayan and this mailing list, but I am happy to have found 
something open source that really seems to meet my needs as a fairly 
lightwight open-source DMS, and can use SQLite (I'm just doing this on my 
local machine, so no real need for a complicated DB setup).

I have started to upload documents, and thinking about customising etc. My 
first thought was to have functionality to bulk-add tags, and I have 
submitted a git enhancement ticket for that 
(https://github.com/rosarior/mayan/issues/31).

The other thing that I thought might be a useful enhancement, at least for 
my needs, was to be able to search only certain metadata fields. For 
instance, if you had a metadata field 'Author' clearly it's useful to be 
able to search for all documents with 'Dickens' as the author. As I 
understand it, currently the metadata search just looks in the 
metadata_documentmetadata table under the value field, so doesn't relate to 
the metadata type. I know Python, but very new to Django, but I had a play 
around with the source and eventually figured out that the lines to change 
were at the bottom of the mayan/mayan/apps/documents/models.py file. I 
registered various combinations of new fields trying to get the field to 
search on the foreign key in the metadata_metadatatype table. 

This included adding 

"{'name': u'metadatatype__name', 'title': _(u'Metadata type')},

to that file, which I thought would enable search on the metadatatype. 
However, I kept getting the message 

"Cannot resolve keyword u'metadatatype' into field. Choices are: comments, 
date_added, description, document_type, documentcheckout, documentmetadata, 
documentrenamecount, documentversion, folderdocument, id, 
indexinstancenode, queuedocument, recentdocument, tagged_items, tags, uuid"

I assume these names related somehow to the document class/app somehow but 
wasn't sure how. 

I was able to make it work by adding:

"{'name': u'documentmetadata__metadata_type', 'title': _(u'Metadata type')},

and changing the comparison type to 'exact', but obviously this isn't 
really a solution as it relies on the user knowing the metadatatype id, 
rather than the name.

So, given that I've got fairly hopelessly lost, can anyone explain what I 
was doing wrong, or why what I was trying to do is impossible? I guessed 
something to do with joining tables but my inexperience is showing.

Essentially what I was looking for was something that could some something 
like the following SQL, which works:

select * from metadata_documentmetadata 
where metadata_type_id = (select id from metadata_metadatatype where name = 
'Author') 
and value like '%Dickens%'

In addition, is there a wider context to this, i.e. is this something that 
has been tried / thought about before, from a functionality or UI point of 
view? Perhaps the consensus is that it isn't even necessary? What would be 
even better would be the option to search for metadata in several fields, 
i.e. author = 'Charles Dickens' and date < 1880.

Any thoughts or pointers welcome.

Regards

Stephen Knox

-- 



Reply via email to