Is it possible to find out if FT index is updated? - full-text-search

I need to find out if a FT index is updated or not on a Domino database. if it is not updated I want to display how many documents are not indexed, possible?

You can do use the database method search(String formula, DateTime dt, int max) to search for documents created or modified after the last index time stamp and then count the number of documents found:
DocumentCollection unindexedColl = db.search("Form=\"specificform\"", db.getLastFTIndexed(), 0);
unindexedCount = unindexedColl.getCount();

Here is code snippet:
If(db.lastmodified > db.lastftindexed) Then
' Database was modified after index updated , it may be a document or design
Dim T As New NotesDateTime(db.lastftindexed)
Dim UnindexedCount As Long
' Find the modified document after index updated
UnindexedCount = db.Search({#All}, T, 0).Count
Else
' FT index is up to date
UnindexedCount = 0
End If
MsgBox UnindexedCount

Related

Query to filter 10% data or top 20 whichever is more

I have a MS Access table with lots of records. I want to create a query to randomly select 10% of records. However, the minimum count of records should be 20. So, if the total count of records is 180, it should ignore the 10% criteria and filter out minimum 20 records.
I have successfully retrieved the 10% data using the Top 10% return setup. I need to apply the minimum 20 records criteria. Can someone please guide me further.
You must count the records and adjust the SQL manually:
Const TopCount As String = "20"
Const TopPercent As String = "10%"
Dim Sql As String
Dim TopValue As String
Dim Records As DAO.Recordset
Sql = "Select Top {0} * From YourTable"
If DCount("*", "YourTable") > 200 Then
TopValue = TopPercent
Else
TopValue = TopCount
End If
Sql = Replace(Sql, "{0}", TopValue)
Set Records = CurrentDb.OpenRecordset(Sql)

Arrays to filter, copy and past - quick macro method

I want to make an Excel workbook that I have much quicker.
I have a big product database with the product names, quantities, delivery number and delivery date (ProductDB). I put in another sheet the products that I have sold (product names and quantity sold) and want to filter and copy those that are corresponding from the database so I can calculate in the second step the remaining quantity and past the remaining quantity to the database.
Everything is working well and the calculation is good. The only thing is, the Advancedfilter xlfiltercopy option is too slow if I have to input 5000 lines of product names.
I have heard that arrays are much faster. How could I do that? The current way I do it is like this:
Sub UseFilter()
Application.ScreenUpdating = False
Sheet1.Range("G1:Z100000").Cells.Delete
Dim lastrow As Long, c As Range
Dim myrange As Range
Dim rngCell As Range
Dim wksSheet As Worksheet
Dim wksSheetDB As Worksheet
lastrow = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
Sheet1.Columns("G").NumberFormat = "0"
Filter product codes from the database according to sold product codes:
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
If Len(c.Value) <> 0 Then
ThisWorkbook.Worksheets(Worksheets.Count).Columns("A:D").AdvancedFilter xlFilterCopy, _
Sheet1.Range("A1:A" & lastrow), Sheet1.Range("G1"), False
End If
Next
Sort the filtered list first by product code, then by the delivery number:
Dim lngRowMax As Long
Dim wsf As WorksheetFunction
With Sheet1
lastrow = Cells(Rows.Count, 8).End(xlUp).Row
Range("G1:J" & lastrow).Sort Key1:=Range("G1:G" & lastrow), _
Order1:=xlAscending, Key2:=Range("I1:I" & lastrow), _
Order2:=xlAscending, Header:=xlYes, DataOption1:=xlSortTextAsNumbers
Set wsf = Application.WorksheetFunction
lngRowMax = .UsedRange.Rows.Count
End With
I'm only interested in filtering and copying of the corresponding product information (name (A), quantity (B), delivery nr (C) and date (D)). Does anyone know how I can do that?
Thank you very much in advance. I'm really looking forward for a solution that improves the pace of the file. Currently it is unbelievably slow.
i had the same problem with advanced filter being so slow. you might want to consider using dictionary. for my 2 spreadsheets i wanted to compare i made 2 dictionaries and compared the values and it was so amazingly fast. dictionaries are really easy and a simple google search you can find a ton of tutorials and examples. good luck.
There is a possible solution with dictionaries, but I have only one small issue. I will explain after the code:
'Count num rows in the database
NumRowsDB = ThisWorkbook.Worksheets(Worksheets.Count).Range("A2", Range("A2").End(xlDown)).Rows.Count
' --------------------- SAVE DATABASE DATA -----------------------
'Dictionary for all DB data
Set dbDict = CreateObject("Scripting.Dictionary")
Set dbRange = Range("A2:A" & (NumRowsDB + 1))
For Each SKU In dbRange
If Len(SKU.Value) <> 0 Then
' check if the SKU allready exists, if not create a new array list for that dictionary entry
' a list is necessary because there can be multiple entries in the db range with the same SKU
If Not dbDict.Exists(CStr(SKU.Value)) Then
Set prodList = CreateObject("System.Collections.ArrayList")
dbDict.Add CStr(SKU.Value), prodList
End If
' for this specific product code, save the range where the product information is saved in the dictionary
rangeStr = "A" & SKU.Row & ":D" & SKU.Row
dbDict(CStr(SKU.Value)).Add (rangeStr)
End If
Next
' ----------- READ SALE/Reverse/Consumption INFO ------------------
NumRowsSale = Range("A2", Range("A2").End(xlDown)).Rows.Count
Set saleRange = Range("A2:A" & (NumRowsSale + 1))
Dim unionRange As Range
For Each sale In saleRange
' check if the SKU for the sale exists in db
If Len(sale.Value) <> 0 And dbDict.Exists(CStr(sale.Value)) Then
For Each dbRange In dbDict(CStr(sale.Value))
If unionRange Is Nothing Then
Set unionRange = Range(dbRange)
Else
Set unionRange = Union(unionRange, Range(dbRange))
End If
Next
End If
Next
unionRange.Copy Destination:=Range("G2") 'copy all received ranges to G2
Set dbDict = Nothing
The line "NumRowsDB = ThisWorkbook.Worksheets(Worksheets.Count).Range("A2", Range("A2").End(xlDown)).Rows.Count" is not working. I have to refer to another sheet (the last sheet which is the current database) to get the data. What is the problem that I cannot refer to another sheet in the same workbook?
Thank you for your suggestions.

Date range comparison in CQ using XPATH

I'm using the following query to get nodes based on last modified date in CQ.
/jcr:root/content/scaffoldes/properties//*[#jcr:primaryType = 'nt:unstructured' and (#sling:resourceType = 'acme/components/content/scaffoldItem' or #sling:resourceType = 'acme-core/components/data/property') and #jcr:content/cq:lastModified >= xs:dateTime('2000-01-01T00:00:00.000-08:00') and #jcr:content/cq:lastModified < xs:dateTime('2014-12-31T00:00:00.000-08:00') and not(#isHidden)] order by #jcr:score
we have used
http://localhost:4502/crx/explorer/ui/search.jsp
To test this query. But, even after giving a huge date range (2000 - 2016) this query is returning nothing.
But If we remove the date range part, this query returns nodes.
Any pointer to correct this would be helpful.
Thanks and Regards,
San
Notes
The date string is create with the following code:
Calendar cal = Calendar.getInstance();
cal.setTime(start);
String startDate = ValueFactoryImpl.getInstance().createValue(cal).getString();
Sorry for any confusion caused. I found that the node which I'm trying to query doesn't have a cq:lastModified property. So modified the query to include the cq:lastReplicated in the condition.
... and ((#jcr:content/cq:lastModified >= xs:dateTime('2000-01-01T00:00:00.000-08:00') and #jcr:content/cq:lastModified < xs:dateTime('2016-02-11T15:52:57.090-08:00')) or (#jcr:content/cq:lastReplicated >= xs:dateTime('2000-01-01T00:00:00.000-08:00') and #jcr:content/cq:lastReplicated < xs:dateTime('2016-02-11T15:52:57.090-08:00'))) and ...

Querying in MS Access 2013 excluding special characters

I am trying to create an update query in MS Access where I will pull a few fields of information from one table if one of the fields matches and the rest are blank. For example:
**Table 1**
SKU Description Weight Lead Time
C210657 NULL NULL NULL
221AB0909 NULL NULL NULL
VA12345 NULL NULL NULL
221AB09 NULL NULL NULL
**Table 2**
SKU Description Weight Lead Time
F-210-223.2 Hammer 2.1 3.1
201-ABF-345 Car 12546.0 65.0
C_210657 Apple 0.2 1.0
34_AA_332 Puppy 5.5 55.0
221 AB 0909 Stereo 12.0 875.0
VA12345_123-A Labor 0.0 0.0
So I want the query to fill in columns 2 through 4 of table 1 with information from table 2. All four of the items in table 1 have a match in table 2, there are just special characters (-, _, ., ), that are in the way. How can I have the query ignore them? Thanks
Which way you go depends on what you're willing to do. If it's a big database, you might want to add a new field [SKU_Index] that is SKU with the special characters removed and link on that.
If that's not a possibility, then you can do a calculated subquery and link on the calculated field...but it can be a little slow.
You would need to write a procedure that removes the special characters from a passed string. Let me know if you would like help with that.
Then you do a query on Table 2 like this:
Select SKU2:RemoveSpecialChars([SKU]), Description, Weight, [Lead Time] From [Table 2];
RemoveSpecialChars() would be your procedure.
You save that query (let's call it PreQuery). Create a new query and bring in PreQuery and Table 1 linking SKU from Table 1 to SKU2 from PreQuery, and update the relevant fields.
Ideally, cause storage is cheap, I would keep a second field without the special characters and perhaps index on it.
Here's example code for how that would work:
Public Function RemoveSpclChars(strIn As String) As String
' Comments : removes any special characters
' Parameters: strIn - string to check
' Returns : resulting string with removed special characters, can be empty
'
Dim lngCounter, intChar As Integer
Dim chrTmp As String * 1
Dim strTmp As String
On Error GoTo PROC_ERR
strTmp = ""
' Walk through the string
For lngCounter = 1 To Len(strIn)
' Get the current character
chrTmp = Mid$(strIn, lngCounter)
intChar = Asc(chrTmp)
' Test if alpha or numeric only
If (intChar >= Asc("a") And intChar <= Asc("z")) Or (intChar >= Asc("0") And intChar <= Asc("9")) Then
strTmp = strTmp & chrTmp
End If
Next lngCounter
PROC_EXIT:
RemoveSpclChars = strTmp
Exit Function
PROC_ERR:
Dim strErr As String
strTmp = "ERROR: " & Trim(Str(Err.Number)) & ":" & Err.Description
Resume PROC_EXIT
End Function

Oracle Apex get Multiple results from checkboxes

DB = Oracle 11g
Apex = 4.2.6
In the form I have various items which all work great. However I now have a set of check boxes(:P14_DAYS) one for each day of the week.
What I need to do is get all records between :P14_START_DATE :P14_END_DATE, but only within the days select that's checked.
Below is also a sample of the DATE_SETS table
http://i.stack.imgur.com/YAckN.png
so for example
dates 01-AUG-14 - 5-AUG-14 But only require Sundays AND Mondays date would bring back 2 refs.
BEGIN
UPDATE MD_TS_DETAIL
SET job_for = :P14_JOBFORTEM,
job_type_id = :P14_JOB_TYPE_VALUE,
account_id = :P14_ACC_VAL,
qty = :P14_HRS,
rio = :P14_RIO,
post_code = :P14_POSTCODE
WHERE id IN (SELECT D.id
FROM MD_TS_MAST M
LEFT JOIN MD_TS_DETAIL D
ON M.mast_id = D.md_id
LEFT JOIN DATE_SETS
ON ms_date = dt
WHERE eng_id = :P14_ENG_VAL
AND ms_date BETWEEN :P14_START_DATE AND :P14_END_DATE
AND DATE_SETS.col_day = ANY instr(':'||:P14_DAYS||':',Return)
END;
Any help would be much appreciated .
I found this example: http://docs.oracle.com/cd/B31036_01/doc/appdev.22/b28839/check_box.htm#CHDBGDJH
As I can understand, when you choose some values in your checkbox list, item :P14_DAYS receives value, that contains return values of chosen elements of the LOV with delimiters. Then you need to replace this string in your query
AND DATE_SETS.col_day = ANY instr(':'||:P14_DAYS||':',Return)
with
AND instr(':'||:P14_DAYS||':', ':'||DATE_SETS.col_day||':') > 0
Here function instr searches substring DATE_SETS.col_day in string :P14_DAYS. It returns position of substring if substring was found or 0, if not found. Then you compare result of function with 0, and if result > 0, it means that DATE_SETS.col_day is among selected values.

Resources